Vector3 Velocity { get; set; }

book_4_sparkGenerated
code_blocksInput

Description

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.

Usage

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

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