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 theHierarchy
panel or theScene
view. - In its
Inspector
panel, click on theAdd Component
button. - Select
New Script
. - Name it
LookMoveTo
. - Ensure that the
C Sharp
language is selected. - Click on
Create
andAdd
.
This should create a script component on the WalkTarget
object. Double-click on it to open it in your code editor.