Skip to main content
Up and Coming
February 18, 2014

Have Head Bone Rotate with OVR Camera Correctly

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 :(
    This topic has been closed for replies.

    7 replies

    Up and Coming
    February 18, 2014
    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;
    }
    CHADALAK1Author
    Up and Coming
    February 18, 2014
    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?
    CHADALAK1Author
    Up and Coming
    February 19, 2014
    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?
    Up and Coming
    February 19, 2014
    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.
    CHADALAK1Author
    Up and Coming
    February 19, 2014
    you sir, are a GOD of fixing my problem!! :D!! thank you tons and tons!!!! :P :D
    Up and Coming
    February 19, 2014
    np :-)
    Up and Coming
    September 10, 2015
    "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!
    Asteria - http://playasteria.com