Tracking whether a character is moving or not,Trying to track whether character is moving or not (Unity 2D)
I'm currently trying to track when an object (objectToFollow) is moving, but the moving bool only becomes true when my character moves diagonally. (Game uses an overhead view)
currentPosition = objectToFollow.transform.position; if (Mathf.Abs(currentPosition.x - lastPosition.x) < 0.001 || Mathf.Abs(currentPosition.y - lastPosition.y) < 0.001) { moving = false; } else { moving = true; } lastPosition = currentPosition;,I'm trying to track whether an object (objectToFollow) is moving or not, but moving seems to only be true when my character is moving diagonally. (Game is in overhead view)
currentPosition = objectToFollow.transform.position; if (Mathf.Abs(currentPosition.x - lastPosition.x) < 0.001 || Mathf.Abs(currentPosition.y - lastPosition.y) < 0.001) { moving = false; } else { moving = true; } lastPosition = currentPosition;