Creating and configuring a config via code
All Nav3DAgentConfig parameters can be configured through the code as well.
To do this, you should create a Nav3DAgentConfig
instance, set correct parameter values, and then apply the instance to the agent.
- It is suggested to use
Nav3DAgentConfig.DefaultConfig
to create a new instance. - There is a
Copy()
method to get a copy of the instance. - To apply config to the agent it is needed to use the
Nav3DAgent.SetConfig(Nav3DAgentConfig _Config)
method.
Below is an example of creating a Nav3DAgentConfig instance and applying it to an agent.
void ConfigureAgentConfig()
{
Nav3DAgent myAgent = GetComponent();
//create Nav3DAgentConfig instance with default parameters
Nav3DAgentConfig myConfig = Nav3DAgentConfig.DefaultConfig;
//set the parameters you want
myConfig.Radius = 1.2f;
myConfig.MotionNavigationType = MotionNavigationType.LOCAL;
//apply config to agent
myAgent.SetConfig(myConfig.Copy());
}