Animate Camera on Button Press

I am putting something together in Maya that I want to be able export and control in Unity. What I am trying to do is create a “menu” where as the user presses the left or right keys on the keyboard, the camera will rotate to the left or right. Think of standing in a room surrounded by a circle of doors. If the user clicks left the camera will rotate to the left to face the next door (and vice versa).

What I am looking for is a good strategy on how to approach this. My preference is to animate a camera in Maya because I am very comfortable in Maya and it would make it easier to coordinate any secondary animation. Can you use a camera from a Maya scene as your Scene Camera or are you stuck with the camera Unity starts you with?


I’m not familiar with Maya, but consider that even if you cannot bring in the camera directly, you can probably bring in a properly animated null / stand-in. The camera might be interpreted by unity as an empty game object. You can add a camera component to this in Unity, or you can line up a chosen camera as a child of this object and it will effectively use your animation.

If you end up doing scripting, here’s a relatively simple approach, though there are likely more efficient ways:

Create an empty game object that shares the same position and orientation as the camera. This can operate as a destination rotation. On this ‘pointer’ object you can put a script that uses LookAt.

On your camera, you can use a script that refers to this object’s orientation, and uses Quaternion.Lerp in Update or a coroutine to rotate to that destination.

Whenever you want to change what the camera looks at over time, you just have the pointer object LookAt the target.

EDIT: in response to the comment, to maintain a clear prefab connection for updating in the editor mode, I suggest you apply a simple script to the camera that will parent and orient it at runtime, so the prefab is preserved in edit mode.

Such a script might be as simple as this:

var cameraNull : Transform;

function Start(){
   transform.parent = cameraNull;
   transform.localPosition =;
   transform.rotation = cameraNull.rotation;

With the camera selected, drag the null to the cameraNull in the inspector. You may need to tweak the rotation if, for example, the null axis is facing the wrong direction.