GUI camera tracking parenting rotation

I have an overhead ortho camera parented to an FPS controller for a tracking GUI view.

Is it possible to keep the camera parented but prevent it from rotating around the Y axis? I’d like to keep the GUI view oriented one direction as the FPS controller turns.

or is there a simple way to script this, unparented?

thanks!!

I haven’t actually tested this. But give it a shot.

var target : Transform;
function LateUpdate ()
{
   transform.position = target.position;
   var euler = target.eulerAngles;
   transform.eulerAngles = Vector3(euler.x, 0, 0);
}

thanks, joachim,

it’s close, i think, but not quite. honestly, i can’t really tell what it’s doing. with the script attached the GUI camera does seem to slide in x, but doesn’t seem to move in z. but i can’t tell where it’s viewing from anymore - seems like it might be taking on the same view as the FPS camera?

i’m assuming this script goes with the ortho cam…correct? and targeting the FPS?

thanks again for your help.

It goes on the ortho camera and you should not parent the ortho camera.

thanks again, joachim, sorry to be such a newb.

it appears that the ortho GUI camera is repositioning to the FPS camera’s position, (i.e. straight ahead), and not following the FPS in z (only tracking in x)

here’s a screenshot, positioned in front of a staircase

What you want to do is switch to 2 view layout. So that you can see scene view and game view at the same time.

Then you want to watch the position of the second game in the scene view. This will give you further clues of what the code is doing exactly and you can then adjust the script to make it fit.

i’ve got it!

thanks very much for your help. here was my adjustment:

var target : Transform;
function LateUpdate ()
{
transform.position.x = target.position.x;
transform.position.z = target.position.z;
}