float Separation { get; set; }

book_4_sparkGenerated
code_blocksInput

Description

The Separation property of the NavMeshAgent class is a float value that determines the separation behavior of the agent in relation to other agents. This property is part of the avoidance group, which helps in managing how agents avoid each other to prevent collisions and maintain a certain distance.

The value of Separation ranges from 0 to 1, where 0 means no separation and 1 means maximum separation. This allows for fine-tuning the agent's behavior in crowded environments.

Usage

To use the Separation property, you can set it directly on an instance of NavMeshAgent. Adjusting this value will affect how the agent maintains distance from other agents during navigation.

For example, if you want the agent to maintain a moderate distance from others, you might set the Separation value to 0.5.

Example

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

// Set the separation value to 0.5 for moderate separation
agent.Separation = 0.5f;

// Use the agent to navigate
agent.MoveTo(new Vector3(10, 0, 10));