O'Reilly logo

Unity 4 Game Development HOTSHOT by Jate Wittayabundit

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a third-person camera to follow our character

From the last section, we got a controllable character with animation, but the camera isn't actually following the character at all. So, in this section, we will create the third-person camera to follow our character.

Engage thrusters

Now, we will create the script to control our character:

  1. We will create the CameraControl script that will control our entire menu; go to Assets | Create | Javascript (for Unity JavaScript users) or Assets | Create | C# (for C# users), name it CameraControl, double-click on it to launch MonoDevelop, and then we will get our hands dirty with the code.
  2. Open the CameraControl script file and type in the following code:
    // Unity JavaScript user: #pragma strict @script ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required