Vector3 Velocity { get; set; }

robot_2Generated
code_blocksInput

Description

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.

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
}