Getting started
Last updated
Last updated
To get started right away simply follow this short tutorial
Create a new empty scene.
Create an empty game object.
Add the PathGridSystem component to the empty game object.
The PathGridSystem component handles adding and removing cells, as well as setting the path network and path preset.
We now need a path network where the path should be created. You can add as many as you like. Create a new empty game object and assign the PathNetwork component to it. The PathNetwork component has some settings:
Grid Cell Size: The size of each cell of the grid
Y Offset: The general Y position offset
Adapt to height: If enabled, the created paths will be deformed based on the underlying Terrain or Mesh. Please make sure that the Terrain or mesh has a collider.
Terrain Layer: The layer of the underlying terrain or mesh.
A path network can be seen as a "closed" network of paths. Each network can of course have multiple path presets. This can be useful if your game has a road network and an additional network for sewage pipes or electricity cables.
Assign the RoadNetwork object to the PathGridSystem.
Assign a path preset to the PathGridSystem. You can use a pre-existing preset located in PathGrid / Presets
The basic setup is now complete. To create a path you now simply have to call the method AddPathTiles and pass a list of Vector3. Following is a simple example:
To set a different network. Simply call the SetPathNetworkIndex on the PathGridSystem and pass the index number. Make sure you have assigned multiple path networks on the PathGridSystem inspector.
To set a different preset. Simply call the SetPathPresetIndex on the PathGridSystem and pass the index number. Make sure you have assigned multiple path presets on the PathGridSystem inspector.
To remove cells simply call RemovePathTiles and pass a Vector3 list with the positions.
Please make sure to check out the demo scenes. Some have additional more advanced input handling scripts which also make use of the PathNetwork grid system to set and get different cell types. If you have A* Pathfinding Project installed in your project you can also open the additional A* Pathfinding example package located in: PathGrid / Demo / Demo_03_AStarPathfinding.