I created a character with animations for iOS platform, walking from frame 2 to 60 and resting (idle) from frame 1 to 1. Then I have applied the following code but when I moved the joystick it doesn’t work. I realized that when I export the game to Mac platform, if I press the up arrow the animation works. Does anyone know how to change the code to work with joysticks?
function Update ()
{
if (Input.GetAxis("Vertical") > 0.2)
animation.CrossFade ("idle");
else
animation.CrossFade ("walk");
}
Oh thanks! I have tested the code for a while but I don’t know how to set up so that my character plays animation “walk” when the joysticks are touched and plays the animation “idle” when nothing is pressed. Can anybody help me to resolve this script?
function Start()
{
animation.Stop();
animation.Play("idle");
}
function Update () {
var fingerCount = 0;
for (var touch : Touch in Input.touches) {
if (touch.phase != TouchPhase.Ended touch.phase != TouchPhase.Canceled)
animation.Play("walk");
}
if (fingerCount > 0)
animation.Play("idle");
}