Setup

Neccessary Setup

Here we star-off with an empty scene. First thing we need to do is save this scene and give it a name. This is neccessary because we can’t create an ECS subscene otherwise.

_images/11.png _images/2.png

Right-click on the scene name and select “New Empty SubScene”

_images/3.png

Give it an appropriate name and save (don’t try to change it’s location).

_images/4.png

Now go to the “Prefabs” folder in this package, find the Grid prefab and place it as a child of the SubScene.

Note

All GameObjects that are supposed to be baked to ECS objects must be placed in a subscene.

_images/5.png

Now place the GridDebug prefab outside of the subscene, so it is a regular GameObject. A grid should show up in the editor.

_images/6.png

Create two new LayerMasks, one for Inaccessible grid nodes and another for nodes with a Penalty. Here I intuitively called them Inaccessiblee and Penalty.

_images/7.png

Set these two LayerMasks in the GridAuthoring component in the Grid that you placed earlier in the subscene.

_images/8.png

Placing Obstacles

Create a new Cube and Make sure to place it in the ECS-Subcene.

_images/9.png

Scale the Cube and place it in one the quarters of the Grid.

_images/10.png

Set the Layer on the Cube to Inaccessible (we created this Lyaer Mask earlier).

_images/111.png

Add an ASObstacleAuthoring component to the Cube. And now it became an Obstacle that Agents will avoid.

Important

Make sure that the Obstacle overlaps with the grid for best result.

_images/12.png

Now dupliacate this Cube 3 more times and place them in the other 3 quarters of the grid like this picture.

_images/13.png

First Agents

Create a new Plane, placing it in the subscene is not too important as it is just a visual element but it would be a good practice to do so. Place the Plane at 0,0,0 and scale it by 3 in all directions.

_images/14.png

Go to the Prefabs folder again, grab the Agent prefab and place it near the corner of the grid. And again, make sure it is inside the ECS-Subcene. You will know it is when the Agent Capsule in Yellow is visible.

_images/15.png

In the ASAgentAuthoring component, check “Ignore Avoidace When Dest Reached” and “Has Init Destination”.

_images/16.png

Now When we press play the Agent will move to the center of the Grid, that’s because the initial destination is set to 0,0,0

_images/17.png

Now dupliacate the agent multiple times and scatter them across the Grid.

_images/18.png _images/19.png