Creating and configuring an agent description from code - Nav3D Doc

Docy Child

Creating and configuring an agent description from code

All Nav3DAgentDescription parameters configured in the description inspector can also be configured from your code.

To do this, you need to create a variable of type Nav3DAgentDescription, then apply it to the agent. The correct way to create a description is to refer to the Nav3DAgentDescription.DefaultDescription property.

After setting the desired parameters in the code, you need to set the description instance to the agent.

If your description contains parameters whose value is configured to be randomly generated, then before setting the description, the agent needs to get a variant of the description with generated parameters. The correct way to get a description instance to set to an agent is to use the Nav3DAgentDescription.GetDescriptionVariant() method. Calling this method guarantees the creation of a separate instance of the description, taking into account the generated parameters. We recommend that you always use the GetDescriptionVariant() method to set the description for an agent via code.

				
					void ConfigureAgentDescription()
{
   Nav3DAgent myAgent = GetComponent<Nav3DAgent>();

   //create Nav3DAgentDescription instance with default parameters
   Nav3DAgentDescription myDescription = Nav3DAgentDescription.DefaultDescription;

   //set the parameters you want
   myDescription.Radius = 1.2f;
   myDescription.MotionNavigationType = MotionNavigationType.LOCAL;
  
   //apply the description to an agent
   myAgent.SetDescription(myDescription.GetDescriptionVariant());
}
				
			

Nav3DSphereShell

Represents a spherical shell that is perceived by other agents as an object to a...

Nav3DEvader

There is also a separate controller, whose behavior consists of just avoiding ne...

Nav3DAgentManager

This class implements several methods to get a list of all Nav3DAgents located i...

Nav3DPathTester

We implemented a useful component (Nav3DPathTester), which can be used while bui...

PathfindingResult

Contains the pathfinding data and time statistics. Time statistics: public TimeS...

Nav3DPath: Events

For the convenience of notification when the pathfinding finished, the following...

Agent log

Here you can copy the contents of the agent log to the clipboard by clicking the...

Debug drawing

In this section, you can visualize the agent and his nearest environment. This s...

Creating and configuring an agent description from code

All Nav3DAgentDescription parameters configured in the description inspector c...

Nav3DManager

Nav3DManager is a helper static class. Can be useful for checking whether Nav3D ...

Nav3DInitializer

To use Nav3D in playmode, you need to initialize it. The Nav3DInitializer compon...

Nav3DObstacleLoader

To use the possibility of pre-baking obstacles on the scene in editor mode and t...

Chat Icon Close Icon
en_USEnglish