- Home /
How do I smoothly rotate a bone based on axis input?
What I'm trying to achieve is that when the character turns left or right, his spine would also bend in that direction to help make him feel more grounded by leaning in.
It's working fine beside one thing; the spine bone snaps to the angle specified instead of smoothly moving towards it, the code is as follows:
var speed = 1;
function LateUpdate () {
if (Input.GetAxis("Horizontal")< 0)
transform.Rotate(Vector3(0,30,0));
if (Input.GetAxis("Horizontal")> 0)
transform.Rotate(Vector3(0,-30,0));
}
What would be the easiest(and cheapest) way to get this to smoothly rotate instead of snap?
Comment
Have a look at quaternions and the Lerp and Slerp functions. Here's the tutorial video.