- Home /
My GameObject does not rotates.
I want a part of a model to have the same Y rotation of the camera. I have a script that rotates perfectly the camera up and down as I want but I don't know how to do that another object takes this rotation.
I have tried with this:
Rshoulder.transform.localRotation = cam.transform.localRotation;
The Rshoulder actually takes the camera rotation but only when it is not in the field of view. Please help me to solve that and if you know how to transfer only the Y rotations tell me.
Thanks.
Answer by Safforn · Jun 29, 2016 at 09:50 AM
Did you try putting it in a LateUpdate()?
Because if theres an animation on the Rshoulder it could overwrite the rotation you just gave it.
Thanks, now it's working! But as I expected it matches the X, Y and Z rotation. Is there a way for matching only the Y rotation?
Try:
Rshoulder.transform.localRotation = new Vector3(Rshoulder.transform.localRotation.x, cam.transform.localRotation.y, Rshoulder.transform.localRotation.z);
Answer by Donator · Jun 29, 2016 at 08:09 PM
It wasn't working but finally I found the solution! Thanks for trying to help!
*I'm using this in the camera and in the shoulder wih the same rotation and sensitivity values and it's working:
camRotationX += Input.GetAxis("Mouse Y") * camSensitivityX;
camRotationX = Mathf.Clamp(camRotationX, -10, 10);
transform.localEulerAngles = new Vector3(-camRotationX, transform.localEulerAngles.y, transform.localEulerAngles.y);
Your answer
Follow this Question
Related Questions
Object won't rotate 2 Answers
Working with 2 scripts 2 Answers
Why when using LookAt to make the turret facing the target it's facing the other direction ? 1 Answer
How can i rotate object smooth without stop ? 2 Answers
rotating platforms list 0 Answers