// Update is called once per frame public virtual void Update() { switch (state) { default: case State.Idle: break; case State.Moving: if (gameObject.GetComponent <Seek>() == null) { seek = gameObject.AddComponent <Seek>(); } if (curFlowField == null) { return; } Cell cellBelow = curFlowField.GetCellFromWorldPos(gameObject.transform.position); Vector3 moveDirection = new Vector3(cellBelow.bestDirection.vector.x, 0, cellBelow.bestDirection.vector.y); ai.dest = curFlowField.getNeighbour(cellBelow, cellBelow.bestDirection); seek.dest = ai.dest; seek.target = ai.target; if ((gameObject.transform.position - finalDest).magnitude < 1) { //Stop movement.stop(); Destroy(seek); state = State.Idle; arrived = true; } break; } }
public void stop() { agent.stop(); }