Our goal is to make Ethan walk to random positions in the scene. To do this, we'll write a script that moves the WalkTarget object to random positions. Ethan will follow it. Writing scripts is an important part of developing with Unity. If you've done anything more than tinker with Unity, you've probably already written at least some scripts. We're going to use the C# programming language to do this.
If you are new to programming, don't panic! We'll provide a general introduction to Unity scripting at the end of this chapter. You can jump to that now and come back if you wish, or just follow along.
For this first script, we'll take it slow. We will attach the script to the WalkTarget object. To do that, follow these steps:
- Select the WalkTarget object in the Hierarchy window.
- In its Inspector panel, click on the Add Component button.
- Select New Script (you may...