Tag Info

New answers tagged

0

1.) You need to update _lookRotation when the mouse is clicked or it never changes so your agent will never look at a new location. Simple Coroutine Example: IEnumerator RotateAgent(Quaternion currentRotation, Quaternion targetRotation) { IsRotating = true; while(current rotation != targetRotation) { transform.rotation = ...


2

There are two options here. Moving the unit at the end of the coroutine (and maybe changing the name of the coroutine) Creating a second coroutine that waits for the first one to finish before executing Now I'll illustrate the examples // 1st option IEnumerator Turn(float _x, float _z) { Vector3 turn = new Vector3 (_x, 0, _z); ...


1

No need for the coroutine, just don't update the position until the rotation has been completed: if(turnComplete){ transform.position = Vector3.MoveTowards(transform.position, targetPosition, Time.deltaTime * smooth); } Getting whether the turn is completed means checking how much more the unit needs to turn. If the remaining angle is small enough ...



Top 50 recent answers are included