void Update() { if (departFlag && !destroyedFlag) { psTime += Time.deltaTime; lastPos = transform.position; speed -= speed * drag * Time.deltaTime; transform.position = transform.position + speed * dir * Time.deltaTime - new Vector3(0, useGravity * 9.8f * Time.deltaTime, 0); transform.LookAt(transform.position + (transform.position - lastPos)); Physics.Raycast(new Ray(lastPos, dir), out hit); if (hit.collider != null) { Vector3 tmp = hit.point - transform.position; if (tmp.magnitude <= speed * Time.deltaTime) { destroyedFlag = true; if (viewID.Equals(GlobalInfo.playerViewID)) { tmp.Normalize(); GlobalInfo.rpcControl.RPC("OnShellAttackedRPC", RPCMode.All, hit.point, hit.normal, tmp, (int)shellKind, viewID, userName); } Destroy(this.gameObject); } } if (psTime > GlobalInfo.shellProperty[(int)shellKind].lifeCycle) { Destroy(this.gameObject); destroyedFlag = true; } } }
// Update is called once per frame void FixedUpdate() { if (departFlag) { Vector3 tmp; psTime += Time.fixedDeltaTime; if (!destroyedFlag) { if (target != null) { tmp = target.position - transform.position; tmp.Normalize(); float ang = Vector3.Angle(transform.forward, tmp); ang = ang * Mathf.PI / 180.0f; transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.LookRotation(tmp), Time.fixedDeltaTime / ang); transform.Translate(new Vector3(0, 0, speed * Time.fixedDeltaTime)); } else { transform.Translate(new Vector3(0, 0, speed * Time.fixedDeltaTime)); } speed += accel * Time.fixedDeltaTime; RaycastHit hit = new RaycastHit(); Physics.Raycast(new Ray(transform.position, transform.forward), out hit); if (hit.collider != null) { tmp = hit.point - transform.position; if (tmp.magnitude < speed * Time.fixedDeltaTime) { for (int i = 0; i < transform.childCount; i++) { if (transform.GetChild(i).tag != "Tail") { transform.GetChild(i).renderer.enabled = false; } } if (viewID.Equals(GlobalInfo.playerViewID)) { tmp.Normalize(); GlobalInfo.rpcControl.RPC("OnShellAttackedRPC", RPCMode.All, hit.point, hit.normal, tmp, (int)kind, viewID, userName); } destroyedFlag = true; } } } if (psTime >= GlobalInfo.shellProperty[(int)kind].lifeCycle) { DestroyImmediate(gameObject); } } }
private void SetAttackState(NetworkViewID viewID, Vector3 pos) { if (Network.isServer) { GetComponent <NetworkView>().RPC("SetAttackState", RPCMode.Others, viewID, pos); } GameObject targetPokemon = null; if (!viewID.Equals(NetworkViewID.unassigned)) // && PokemonList.instance.ContainsKey(instanceID)) { targetPokemon = NetworkView.Find(viewID).gameObject; //targetPokemon = PokemonList.instance[instanceID]; } selectedMove.SetTarget(new MoveTarget(targetPokemon, pos)); canMove = nav.updatePosition = false; // Then, the LaunchAttackAnim is called from the Rotating() method. }
void Update() { if (departFlag) { psTime += Time.deltaTime; if (!destroyedFlag) { speed += accel * Time.deltaTime; lastPos = transform.position; transform.position = transform.position + speed * dir * Time.deltaTime; transform.LookAt(transform.position + dir); Physics.Raycast(new Ray(lastPos, dir), out hit); if (hit.collider != null) { Vector3 tmp = hit.point - transform.position; if (tmp.magnitude <= speed * Time.deltaTime) { for (int i = 0; i < transform.childCount; i++) { if (transform.GetChild(i).tag != "Tail") { transform.GetChild(i).renderer.enabled = false; } } if (viewID.Equals(GlobalInfo.playerViewID)) { tmp.Normalize(); GlobalInfo.rpcControl.RPC("OnShellAttackedRPC", RPCMode.All, hit.point, hit.normal, tmp, (int)shellKind, viewID, userName); } destroyedFlag = true; } } } if (psTime > GlobalInfo.shellProperty[(int)shellKind].lifeCycle) { Destroy(this.gameObject); destroyedFlag = true; } } }