- Home /
Have Head Bone Rotate with Camera
Posted: 04:33 AM 1 Hour Ago I'm having a huge issue with the head bone not rotating with the camera. when i do this
public Transform cameraObject; //I'm using a transform because I'm using the Oculus Rift for it's rotation
public Transform headBone;
void Update()
{
headBone.rotation = cameraObject.rotation;
}
what happens is the head bone freaks out and seems like the bone is rotating infinitely. any idea how to fix this???
Answer by DerWoDaSo · Feb 18, 2014 at 12:44 PM
I guess you want to control the head bone with the occulus rift rotation, right?
A problem might be local and world rotation. If you set Transform.rotation it applies a the rotation without respect to it's parents rotation. If you read Transform.rotation you will get the world rotation, which is affected by the transform hierachy.
The opposite would be setting/getting the Transform.localRotation, which actually represents the rotation values you can see on the Transform component in the Inspector, which are relative to it's parent transform.
the problem is if i even do this,
headBone.rotation = cameraObject.localRotation;
it doesn't rotate with the camera every frame. It does it as if it was from the Start function... I even have the code in the Update function :(
The problem with that is if i do this
headBone.rotation = cameraObject.localRotation;
it wont update the rotation every frame. just right from the start. and it is in the Update function :(...
$$anonymous$$ight be a silly question, but can you verify the transform you specify as cameraObject is actually rotating?
actually, the silly question was right :P ... so I decided to switch to one of the OVR cameras... but i noticed it freaks out either way with the localRotation. maybe i should ask the forums on Oculus?
void LateUpdate()
{
neckRotation.rotation = camRotation.rotation * Quaternion.Euler(-180,0,90);
}
I FIXED IT!! THAN$$anonymous$$S TO THIS LIN$$anonymous$$ from oculus unity4 support
Answer by H_Alhusban · Feb 18, 2014 at 12:13 PM
try just making the camera a child for the head bone then apply the camera-look script to the camera .