bool UpdatePosition { get; set; }

robot_2Generated
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 prefer to manually control the position, set UpdatePosition to false and use the AgentPosition property to get or set the position:

agent.UpdatePosition = false;
Vector3 manualPosition = agent.AgentPosition;
// Perform custom position updates here

Example

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

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

// Disable automatic position updates and handle manually
agent.UpdatePosition = false;
Vector3 currentPosition = agent.AgentPosition;
// Custom logic to update position
agent.AgentPosition = new Vector3(10, 0, 5);