The Velocity
property of the NavMeshAgent
class represents the current velocity of the agent. This property provides a Vector3
value that indicates the speed and direction at which the agent is currently moving.
The Velocity
property of the NavMeshAgent
class represents the current velocity of the agent. This property provides a Vector3
value that indicates the speed and direction at which the agent is currently moving.
Use the Velocity
property to get the current velocity of the NavMeshAgent
. This can be useful for determining how fast the agent is moving and in which direction, which can be used for animations or other logic that depends on the agent's movement.
// Example of accessing the Velocity property NavMeshAgent agent = new NavMeshAgent(); Vector3 currentVelocity = agent.Velocity; // Use the velocity for some logic if (currentVelocity.Length > 0) { // The agent is moving // Implement logic based on the agent's movement }