I have a car setup, sorta similar to Mario Kart, the steering is controlled by and analog stick is it possible to set steering to the left to play my "leftlean" animation and when steering to the right play my "rightlean" animation? I tried this
function Update ()
animation.wrapMode = WrapMode.Clamp;
animation.Play("leftlean"); // name of the animation clip
With no luck, any help?
Input.GetAxis("Horizontal") doesn't return a bool. It returns a float, between -1(left) to 1(right). During your if statement on line 3 you could instead check this:
if(Input.GetAxis("Horizontal") > 0 || Input.GetAxis("Horizontal") < 0)
This would let you know that the controls had been moved.
Then, if it was greater than 0 you could play your right animation, and vice versa for left.