float MaxSpeed { get; set; }

robot_2Generated
code_blocksInput

Description

The MaxSpeed property of the NavMeshAgent class specifies the maximum speed at which the agent can move along the navigation mesh. This property is crucial for controlling the movement speed of the agent within the scene, allowing for dynamic adjustments based on gameplay requirements.

Usage

To set the maximum speed of a NavMeshAgent, simply assign a float value to the MaxSpeed property. This value should be positive and represents the speed in units per second.

Example

// Create a new NavMeshAgent instance
NavMeshAgent agent = new NavMeshAgent();

// Set the maximum speed of the agent
agent.MaxSpeed = 5.0f;

// Use the agent to move to a target position
Vector3 targetPosition = new Vector3(10, 0, 10);
agent.MoveTo(targetPosition);