Description
The AgentMaxSlope
property specifies the maximum slope, in degrees, that an agent can walk up. This property is crucial for defining the navigable terrain for AI agents, ensuring they do not attempt to traverse slopes that are too steep for their capabilities.
Usage
Use the AgentMaxSlope
property to set or get the maximum slope angle that an agent can navigate. This property is part of the NavMesh
class, which is used to define navigation parameters for AI agents in a scene.
To adjust the maximum slope, simply assign a new value to this property. Ensure that the value is within a realistic range for your application, typically between 0 and 90 degrees.
Example
// Example of setting the AgentMaxSlope property
NavMesh navMesh = new NavMesh();
navMesh.AgentMaxSlope = 45.0f; // Set the maximum slope to 45 degrees
// Retrieve the current maximum slope
float currentMaxSlope = navMesh.AgentMaxSlope;
// Output the current maximum slope
// Note: Avoid using Console.WriteLine in Sandbox
// Instead, use a logging system or in-game UI to display this information
// Log.Info($"Current Max Slope: {currentMaxSlope}");