bool UpdatePosition { get; set; }

book_4_sparkGenerated
code_blocksInput

Description

The UpdatePosition property of the NavMeshAgent class determines whether the position of the associated GameObject is automatically updated to match the agent's position on the navigation mesh every frame. When set to true, the GameObject will follow the agent's position. If set to false, you can manually control the GameObject's position using the AgentPosition property.

Usage

To use the UpdatePosition property, simply set it to true or false depending on whether you want the GameObject to automatically follow the agent's position:

NavMeshAgent agent = new NavMeshAgent();
agent.UpdatePosition = true; // Automatically update GameObject position

If you want to manually control the position, set UpdatePosition to false and use the AgentPosition property to set the position:

agent.UpdatePosition = false;
agent.AgentPosition = new Vector3(10, 0, 5); // Manually set position

Example

// Example of using UpdatePosition property
NavMeshAgent agent = new NavMeshAgent();

// Enable automatic position updates
agent.UpdatePosition = true;

// Disable automatic position updates and manually set position
agent.UpdatePosition = false;
agent.AgentPosition = new Vector3(10, 0, 5);