- Home /
How to set child position and rotation fixed respect parent?
Hello,
I have a camera that I rotate along with the gyroscope:
transform.localRotation =
// Allow user to drag left/right to adjust direction they're facing.
Quaternion.Euler(0f, -dragYawDegrees, 0f) *
// Neutral position is phone held upright, not flat on a table.
//Quaternion.Euler(90f, 0f, 0f) *
// Sensor reading, assuming default `Input.compensateSensors == true`.
Input.gyro.attitude *
// So image is not upside down.
Quaternion.Euler(0f, 0f, 180f);
But the problem is that I have gameobjects children of this camera. And they moved along with the camera rotation. I just want to lock them in the same position always independently of the parents move and rotation.
I have tried to save the rotation and position of the objects in Awake() or Start() and then assign it again in Update() but it is not working. I have tried many things but still moving.
Please any help is welcomed.
Thanks
Just to clarify, why do you have these gameObjects be children of the camera in the first place? (There may be a different way to handle that need.)
HI @JPhilipp actually I have tried with them outside the main camera (so not as children) and it happens something similar. It is like I am changing the localrotation of the camera and the objects are rotating as well. Which I think is right but I just want to have them fix in a side of the camera. $$anonymous$$aybe is because I have a VRCamera as a parent. I don't really know. )
Your answer
Follow this Question
Related Questions
How to freeze the rotation or the position on the camera transform? 1 Answer
Child affecting parent rigidbody? 1 Answer
Need help on the 3ds max style camera control 0 Answers
Why the control with gyroscope inverted when I make 180 degrees turn? 1 Answer
Mouse.position from center of player 1 Answer