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
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