camera following a parent without inheriting rotation?

I have a unique issue. Maybe someone out there can help. I have a maze game that involves a player navigating a 3d maze which is wrapped around a sphere. Imagine Super Mario Galaxy meets that David Bowe movie Labyrinth. My issues comes in the form of an overhead camera. When I place the camera as a child of the moving player it rotates with the player. But this causes it to appear as though the map is moving and not the player. I would like the camera to stay constantly positioned above the player but without mimicing the rotation. Is that possible?

I have already tried the transform.LookAt(); from the scripting ref, as well as trying to disconnect the parent to child relationship.Niether was successful. I believe the problem is that the player rotates to stay aligned to the planet’s surface but rotates on it’s local X axis to manuever. Can I lock out just the x axis in the parent to child relationship?

If you need examples or whatever let me know and thank you for you help.

this is really simple in the standard assets there is a SmoothFollow.js this javascript you have to give at the camera anf then give it a target
thats the player and this nice script has made the axis as variable so you can say how high and far away the camera haves to stay.
i think this will solve it. say it if you dont understand, if it didnt work or you want to know more about it.
i will really like to help you ! if this is not excactly what you want then i think i misunderstand it and i will try to help you again.
,nalim

I’d write a script for the camera where basically you position it according to the target object position. In that way you avoid the rotation due to the parenting :slight_smile:

To Nalim - I have attempted to us that script but it does not work. When my player passes over the “equator” of the planet it flips upside down, and the controls seem reversed. To akta - how exactly could I set my camera to always align to my player’s Y axis, and not follow it’s rotation? Thanks for your quick replies and again for your help.

something like this:

var targetObject : GameObject;
var offsetX : float = 10.0;

function Update() {
     transform.position.x = targetObject.transform.position.x - offsetX;
}

if you apply this script to your camera and add a targetObject, the camera x position will move according to the targetObject x minus the offsetX. The offset is needed, otherwise the camera will have the exact position as the target object. Hope you got the idea :slight_smile:

This works really well to lock the camera above the player object, but want I move East or West it does really odd things. Any suggestions on what player controls should be used?