Join Jesse Freeman for an in-depth discussion in this video Creating a grid in Unity IU, part of Unity 5 2D: Pathfinding.
- So now that we know that the search is actually working,…let's create a way to visualize what the map…and our search actually looks like.…From the GameObject menu,…go to the UI and create a new image.…Once we have a new canvas,…let's create an empty game object as well.…We're going to call the empty game object MapGroup,…and let's add a grid layout group component to it.…Here, we're going to change the cell size…to 16 by 16.…We'll give the spacing of two by two…so we can see each of the tiles inside of our grid.…
Let's change the child alignment to Middle Center,…and we'll change the constraint to Fixed Column Count,…and we'll set this to five since our grid is five by five.…Now let's drag our image into the MapGroup…and double-click on the MapGroup…so we can see it in our scene.…Let's copy the image and paste it 24 more times…so we have our five by five grid.…Let's save our scene…and go back into the pathfinding test script.…In order for us to work with Unity's new UI,…we are going to need to import its namespace.…
- What is A*?
- Adding node classes and properties
- Storing and indexing graph nodes
- Building the search class
- Traversing the nodes
- Searching adjacent nodes
- Testing the search
- Building a test map
- Creating and coloring a grid