Book Image

Creating E-Learning Games with Unity

By : David Horachek
Book Image

Creating E-Learning Games with Unity

By: David Horachek

Overview of this book

Table of Contents (17 chapters)
Creating E-Learning Games with Unity
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Extending the GameCam script


The GameCam script's logic needs to be extended for this mission to support the ability to look up in the sky and back down at the player. To do this, a couple of simple methods need to be added to adjust the lookat GameObject.

A public method named LookUp will find the object named lookUpTarget and swap the lookObj in the script with the following code snippet:

public void LookUp()
{
   GameObject go = GameObject.Find("lookupTarget");
   if (go)
      lookObj = go;
}

Note

lookUpTarget is an empty GameObject parented to the player, placed 100 units above him or her in Y—a simple and effective way of looking up above the player.

A second method, named LookPlayer, will restore the lookObj back to the player object. This resets the camera back to third person functionality as shown in the following code snippet:

public void LookPlayer()
{
  if (trackObj)
    lookObj = trackObj;
}