How to transform.Rotate a second camera?

I have a second camera in my scene, which is a top-down camera that I’ve added as a type of map overview camera. The camera is a child of the player game object. It works fine as long as the player is on level ground. Once the player begins to climb a hill, the top-down camera tilts at the same angle as the slope of the hill. I want the camera to always be looking straight down on the player, regardless of the terrain the player in on.

So, my question is how do I maintain the transform.Rotation of my second camera for the Z axis (which is the axis that points to my player) to be always looking straight down? I do not want the camera to tilt at all. I want it to be a straight down “bird’s eye” view.

Thank you for your help,
Calixto

A simple solution would be to not have the camera a child of the player, but have the camera track the player. Rotate your camera to point down, calculate the height you want above the player, attach this script to the camera, then drag and drop the player game object on the ‘player’ variable. The result will be a camera that is always overhead the player but does not rotate with the player. A couple more lines of code beyond this can ease the camera movement if you like.

#pragma strict 

public var player : transform;
public var height = 10.0;

function LateUpdate() {
     transform.position = player.position + Vector3.up * height;
}