Game Development Reference
In-Depth Information
Step 16. Create a new JavaScript file and call it orbit . Enter the code
in Listing 2.1 .
Listing 2.1 Script to Make a Game Object Move in a Circular
Path Around Its Starting Position
private var radius: float = 30;
private var startPosition: Vector3;
private var speed: int = 3;
function Start()
startPosition.x = this.transform.position.x;
startPosition.z = this.transform.position.z;
function Update ()
transform.position.x =
radius * Mathf.Sin(Time.fixedTime * speed) + startPosition.x;
transform.position.z =
radius * Mathf.Cos(Time.fixedTime * speed) + startPosition.z;
Step 17. Attach the JavaScript to the Sphere.
Step 18. Select SphereCam from Hierarchy such that the Camera
Preview window opens in Scene.
Step 19. Ensure that you can see both Game and Scene views and
press play.
Step 20. The camera preview for the SphereCam will display
a moving scene as the Sphere moves about within the
Step 21. Create a Plane and position and orientate it as shown in
Figure 2.10 .
Note: Steps 22-25 are only possible in the Pro version of Unity as the
free version does not have the option Render Texture .
Step 22. In Project, select Create > Render Texture. Rename it to
Step 23. Select SphereCam in the Hierarchy and in the Target
Texture property of the Camera component select and set
sphereCamView. If you select sphereCamView from the Project,
you will see the view captured by SphereCam on this new
texture's surface in the Inspector.
Step 24. Drag and drop the sphereCamView render texture onto
the new plane in the Scene.
Search Nedrilad ::

Custom Search