- Home /
Head bone snap-looking up while trying to look down
Hello, I want to make a head-neck bone that looks and the camera follows, heres my code
using UnityEngine;
using System.Collections;
public class HeadControl : MouseSensitivity {
private float startingRotation;
private float mouseY;
public float bendLimit;
void Start () {
startingRotation = transform.localRotation.x;
mouseY = startingRotation;
}
void LateUpdate () {
mouseY += Input.GetAxisRaw ("Mouse Y") * ySensitivity * Time.deltaTime;
mouseY = Mathf.Clamp (mouseY, startingRotation - bendLimit / 2, startingRotation + bendLimit / 2);
transform.localRotation = Quaternion.Euler (mouseY, 0, 0);
}
}
Sometimes, however, my character's head snaps up a little when looking down.
Any ideas? Is it because of LateUpdate?
Comment
I'm going out for a bit, but if I have a reply Ill answer it in a while.
Ok this only happens when facing a certain direction. I added a horizontal look rotation to the overall character, and when I face with around 0 y rotation, and look down, I see the sun again for a split second, as if I'm still looking up.