- Home /
How to rotate the head in the direction of the camera
How can i let the head rotate with the camera when looking up or down?
My thoughts are that i have to make a script that rotate the head, someone said to me i have to use a "look transform" to get this. After writing the script i have to attach it to the headbone which in this case is Bone_002
I have tried to attach the default MouseLook script to it. but it doesn't seems to work very well (the head will rotate in a strange way). I tried to change the numbers in for what angle the max and the min are to rotate, but it seems to ignore that.
Any clue to let this work? Can someone write a script for me so i can understand whats going on? im still new on scripting and im slowly understanding how it works, im using javascript.
I wish the head to move up and down not sideways.
Answer by CanCo · Sep 15, 2013 at 01:53 AM
If you're using Mecanim use this:
var head : Transform;
var rotationOffset : Vector3;
function Update () {
transform.rotation.eulerAngles = head.rotation.eulerAngles+rotationOffset;
}
if you're using Legacy animations just use LateUpdate.
If this doesn't work, I will most likely fix it because I haven't tested it.
Or you can just put the Mouse rotating script onto the head and have the camera as a child of the head.