The Velocity
property of the NavMeshAgent
class represents the current velocity of the agent as a Vector3
. This property provides the speed and direction at which the agent is currently moving within the scene.
The Velocity
property of the NavMeshAgent
class represents the current velocity of the agent as a Vector3
. This property provides the speed and direction at which the agent is currently moving within the scene.
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 }