Hi. I have set a camera as a child for my sprite, it is following it from up, looking down. However I only want the cam to follow the sprite and do not “turn” on Y axis.
I have applied a rigidbody to the camera and checked lock Y axis rotation, but it does not have any affect.
So my question is how to override the settings for the cam, in order to stop it turning with the sprite, I want only to follow it on X and Z angles. Thanks!
Instead of childing, you could write a simple follow script, which wont take target y in consideration.
it can be solved in many ways:
1: Assign Script to Camera
function Update(){
//transform.localEulerAngles.y=0;
transform.localRotation.y=0; //or any initial value that you want
}
2: you can also assign in parent script
function Update(){
//transform.GetChild(0).localEulerAngles.y=0;
transform.GetChild(0).localRotation.y=0;//or any initial value that you want
}
Thank you both for your suggestions. Basically, after I posted this question I figured out another method, before you could answer.
I created an empty object and I set the camera to it as child. And that empty object is constantly set to the x and z position of the sprite while moving, but not the Y axis. So it does not rotate but following the object.