how can i know if this transform is moving ???
i wanna know if this transform is moving or not, and i'm not use rigidbody, i use navmeshagent, how can i know that ??. Or maybe better, I can check if this transform is moving or not, without using navmeshagent
Answer by I5 · Sep 13, 2018 at 03:25 PM
If you don't want to use the nav agent, this will work (you'll probably want to comment out the Debug.Log after testing):
         private Vector3 lastUpdatePos = Vector3.zero;
         private Vector3 dist;
         private float curentSpeed;
         protected virtual void Update() {
             dist = transform.position - lastUpdatePos;
             currentSpeed = dist.magnitude / Time.deltaTime;
             lastUpdatePos = transform.position;
             Debug.Log(gameObject.name + " movement speed is:" + currentSpeed);
          }
 
               Or, if you want simpler, and are ok with using the nav agent, just call/check navAgent.velocity in Update
Your answer
 
             Follow this Question
Related Questions
my bullets are flaoting upwards and i dont know why? 1 Answer
How do i move a cube by one of its Vertices/Vertex 1 Answer
Move a player in the direction he is facing. 1 Answer
Can work check distance with lerp position? 0 Answers
A strategy for puzzle games: Transform or RectTransform or both? 0 Answers