Paths are usually created by connecting waypoints together. So, we'll set up a simple path, as shown in the following screenshot, and then make our cube entity follow along the path smoothly. Now, there are many ways to build such a path. The one we are going to implement here could arguably be the simplest one. We'll write a script called Path.cs
and store all the waypoint positions in a Vector3
array. Then, from the editor, we'll enter those positions manually. It's bit of a tedious process right now. One option is to use the position of an empty game object as waypoints. Or, if you want, you can create your own editor plugins to automate these kind of tasks, but that is outside the scope of this book. For now, it should be fine to just enter the waypoint information manually, since the number of waypoints that we are creating here are not that substantial.
First, we create an empty game entity and add our path script component, as shown in the following screenshot...