Initialization
All asset classes you need to work with are contained in the Nav3D.API namespace. So after importing the asset, include this namespace in the game script from which you plan to initialize Nav3D.
Nav3DManager
using Nav3D.API
Next, you need to call the initialization function in the main manager.
Nav3DManager.InitNav3D(1f)
The only initialization argument float _MinBucketSize is the minimum size of cells in the pathfinding graph.
All game agents that will perform pathfinding using Nav3D have their own size, determined by the radius that you give them when they are created. (This will be discussed a little later). The minimum cell size must be equal to the maximum of the agents’ radii, this will ensure that the agent can follow any path on the graph.
If there are agents on the stage whose radius exceeds the minimum cell size of the navigation graph, then situations are possible when the agents touch obstacles on the stage. In the future, we will implement a pathfinding algorithm that takes into account the size of the agent.
If you try to use public methods from classes in the Nav3D.API space before the Nav3DManager is initialized, a Nav3DManagerNotInitializedException will be thrown.
using Nav3D.API;
using UnityEngine;
class YourGameScenario : MonoBehaviour
{
private void Start()
{
Nav3DManager.InitNav3D(1f);
}
}
For your convenience, the Nav3DManager
class has the bool Inited
property, which will allow you to determine from other scripts whether the Nav3D has already been initialized.
There is also an event Action OnNav3DInit
that fires immediately after a successful Nav3D initialization. By subscribing to it, you will be able to perform any actions immediately after the initialization of Nav3D. When subscribing to an event, the delegate will fire even if the initialization has already been completed.