In this next script, instead of being random, we'll send Ethan to wherever we look. In Unity, this is accomplished by using ray casting. It's like shooting a ray from the camera and seeing what it hits (for more information, visit http://docs.unity3d.com/Manual/CameraRays.html).
We're going to create a new script, which will be attached to WalkTarget like before, as follows:
- Select the WalkTarget object in the Hierarchy panel or the Scene view.
- In its Inspector panel, click on the Add Component button.
- Select New Script.
- Name it LookMoveTo.
- Ensure that the C Sharp language is selected.
- Click on Create and Add.
This should create a script component on the WalkTarget object. Double-click on it to open it in your code editor.
This LookMoveTo script replaces the RandomPosition one we created before. Disable the RandomPosition component of...