Description
The UpdateRotation
property of the NavMeshAgent
class determines whether the GameObject's rotation is automatically updated to face the direction it is moving. This property is not configurable, meaning it will always orient the GameObject to face its movement direction unless explicitly turned off. If you require specific rotation behavior, it is recommended to disable this property and handle the rotation manually.
Usage
To use the UpdateRotation
property, simply set it to true
or false
depending on whether you want the GameObject to automatically face its movement direction:
NavMeshAgent agent = new NavMeshAgent();
agent.UpdateRotation = true; // Enable automatic rotation
To disable automatic rotation and manage it manually:
agent.UpdateRotation = false; // Disable automatic rotation
// Implement custom rotation logic here
Example
// Example of enabling automatic rotation
NavMeshAgent agent = new NavMeshAgent();
agent.UpdateRotation = true;
// Example of disabling automatic rotation and handling it manually
agent.UpdateRotation = false;
// Custom rotation logic can be implemented here