cancel
Showing results for 
Search instead for 
Did you mean: 

Have Head Bone Rotate with OVR Camera Correctly

CHADALAK1
Explorer
When i attach the camera to the head bone, it works fine, but when I program it to rotate the bone with one of the cameras, the head freaks out :/. any idea what to do to fix 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.localRotation;

}


this is an example of what i put to make it work 😞
7 REPLIES 7

Tamulur
Explorer
Use the camera's global rotation instead of localRotation, and use LateUpdate instead of Update. This will let the head follow your real head's orientation. Also, don't parent the camera to the bone; its orientation is set by the Rift's sensors and when you rotate its parent you rotate it away from the correct angles.

void LateUpdate()
{
headBone.rotation = cameraObject.rotation;
}

CHADALAK1
Explorer
alright. I got it to stop figiting.... problem is the head is sideways... and its COMPLETELY backwards O_o.... looks like some exorcist crazy stuff XD!! but the head rotates and everything... is it possible to fix the orientation of the bone to the camera so it's not looking directly behind itself?

CHADALAK1
Explorer
alright, so i figured out it is the orientation of my bone compared to the orientation of my camera. Now, is there a way to change the orientation of my camera OR do i need to change the orientation of my bone? cause i have my X axis going down the chain of my bones(which is what i've been taught....).

any advice?

Tamulur
Explorer
You can correct for the different orientation when rotating the bone:


public Vector3 neckCorrectionEuler;

void LateUpdate()
{
headBone.rotation = cameraObject.rotation * Quaternion.Euler (neckCorrectionEuler);
}


During runtime, change the avatar's neckCorrectionEuler in its inspector until it looks right (for most avatars, it's something like -90, 0, 0 or so), then enter those values outside of playmode.

CHADALAK1
Explorer
you sir, are a GOD of fixing my problem!! :D!! thank you tons and tons!!!! 😛 😄

Tamulur
Explorer
np 🙂

LoneCoder
Honored Guest
"Tamulur" wrote:
You can correct for the different orientation when rotating the bone:


public Vector3 neckCorrectionEuler;

void LateUpdate()
{
headBone.rotation = cameraObject.rotation * Quaternion.Euler (neckCorrectionEuler);
}


During runtime, change the avatar's neckCorrectionEuler in its inspector until it looks right (for most avatars, it's something like -90, 0, 0 or so), then enter those values outside of playmode.


Thanks a million Tamulur! Totally solved my exact problem quickly and efficiently. You are a man of great character!