Getting started

To get started right away simply follow this short tutorial

  1. Create a new empty scene.

  2. Create an empty game object.

  3. Add the PathGridSystem component to the empty game object.

PathGridSystem component with already assigned PathNetworks and PathPresets

The PathGridSystem component handles adding and removing cells, as well as setting the path network and path preset.

  1. 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.

  1. Assign the RoadNetwork object to the PathGridSystem.

  2. Assign a path preset to the PathGridSystem. You can use a pre-existing preset located in PathGrid / Presets

  3. 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:

public PathGridSystem pathGridSystem; //Reference to the PathGridSystem

public List<Vector3> path = new List<Vector3>();

public void Start()
{
    // That's it
    pathGridSystem.AddPathTiles(path);
}

Addendum

Set a different path network

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.

Set a different path preset

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.

Remove path cells

To remove cells simply call RemovePathTiles and pass a Vector3 list with the positions.

Demo Scenes

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.

Last updated