

First, you will learn about the Command design pattern. You can’t use these methods yet, but you will soon. ResetToLastCheckpoint resets the bot’s location to the last checkpoint. When the bot crosses a new checkpoint, it becomes the last checkpoint for the bot. To solve the maze, the bot should reach the green checkpoint. In the maze, there are points referred to as the checkpoints. The Shoot method makes the bot shoot a projectile that can destroy the yellow walls but is useless against other walls.įinally, take a look at the ResetToLastCheckpoint method to understand what it does, take a look at the maze. Based on the chosen CardinalDirection, the bot will move by exactly one square across the grid in the corresponding direction. An enumerator of type CardinalDirection can be either Up, Down, Right or Left. Notice that the Move method accepts an input parameter of type CardinalDirection. Again, you don’t need to worry about what happens inside these methods but you need to understand how to use them. But take note of the two methods named Move and Shoot. You don’t need to know about what is happening in the Bot script. Navigate to RW/Scripts and open the Bot script in your code editor. You will use this component while issuing input commands. Take a look in the Inspector, and you will see that it has a Bot component attached to it. Select it from the Hierarchy by clicking on it. The most interesting part of this scene is the Bot GameObject. That’s OK because you will add that functionality in this tutorial. If you click Play, the instructions won’t seem to be working. The floor’s design is like as a grid, which will be useful visually when you make the bot move across the maze. You will notice that the scene contains a bot inside a maze, and there is a terminal UI that displays instructions. Unzip the file and open the Starter project inside Unity. To set things in motion, download the project materials using the link at the top or bottom of this tutorial. This tutorial uses Unity 2019.1 and C# 7. Note: This tutorial assumes that you are already familiar with Unity and have intermediate C# knowledge.
