-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Unity Virtual Reality Projects
By :

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—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:
WalkTarget
object in the Hierarchy panel or the Scene view.LookMoveTo
.This should create a script component on the WalkTarget
object. Double-click on it to open it in the MonoDevelop code editor.
In our script, each time Update()
is called, we'll read where the camera is pointing (by using its transform position and rotation), cast a ray in that direction, and ask Unity to tell us where it hits the...