Description
The AgentPosition
property of the NavMeshAgent
class provides the current position of the agent within the navigation mesh. This property is updated with the agent's position, even if the UpdatePosition
property is set to false
. This allows for manual handling of the agent's position updates if desired.
Usage
Use the AgentPosition
property to retrieve the current position of the NavMeshAgent
in the navigation mesh. This can be useful for custom logic that requires knowledge of the agent's position without automatically updating the GameObject's position.
Example
// Example of accessing the AgentPosition property
NavMeshAgent agent = new NavMeshAgent();
Vector3 currentPosition = agent.AgentPosition;
// Use the current position for custom logic
if (currentPosition.x > 10)
{
// Perform some action
}