- Home /
How do I set a child object to not rotate if the parent WILL be rotating?
I just want a camera object to move around and not rotate using c# code.
This object is a camera and it's a child of a car object. The car rotates but I don't want the camera to rotate. I want it to be fixed but following the car from a top down perspective. The camera follows the car no problem, It just rotates when I rotate the car.
I want to keep the camera as a child object because in my game I instantiate up to 4 players and each player car will have a child camera instantiated with them.
The game is a top down racing game.
Here is an image of how it looks:
Answer by whydoidoit · Mar 23, 2013 at 11:59 AM
You have to use code for that - either to negate the rotation of the parent on the child camera or to have the camera follow the player.
If you want to keep it as a child adding this script may help:
FixRotation.cs
Quaternion rotation;
void Awake()
{
rotation = transform.rotation;
}
void LateUpdate()
{
transform.rotation = rotation;
}