From the course: Unity 5: 2D Movement in an RPG Game

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Expand vision

Expand vision - Unity Tutorial

From the course: Unity 5: 2D Movement in an RPG Game

Start my 1-month free trial

Expand vision

- [Voiceover] So now let's look into how we can expand the vision around the player as he visits tiles on the map. Let's go back into our RandomMapTester class and at the top of our class, underneath our player heading, let's go ahead and create a new public int to store the distance that the player can view. Now this value is going to be set as an odd number. One would be a single tile that the player is currently on. Three will expand out in one tile in each direction where the player is the center. Five will expand out two tiles, and so on and so forth. This is important to remember because we use this distance to understand how many tiles around the player in the grid we're going to visit every time the player moves. Let's go down to our visit method and take a look at how we can modify it to see more tiles. At the top of our class, we're gonna add some new variables. Each of these variables are going to be typed to an int and will create a column, a newX, a newY, and a row equal…

Contents