- Home /
What do I need to add to make an iOS joystick movement have my character animate?
I am totally at my wits end with this one. I have tried to find the answer everywhere and I can't find it. I would REALLY appreciate help on this one. I have created a character in Mixamo's Fuse and created a skeleton. I have also animated it. I am using the following javascript to animate it within the game and it works great while playing it on my Mac! Now for the problem. I am creating the game for the iPhone. I have created a touchpad area at the bottom of the screen. The character moves around great but the only animation I get is the idle animation. He just slides across the ground in the direction that I slide my finger on the touchpad. I used the "Player Relative Controls" prefab that came with the mobile assets. And again, it works great but the character won't animate. I have tried everything I could think of or find to put into the input axes and nothing works. I have tried a lot of different code attempts but I can't seem to get it to work. Could someone please tell me what I am missing or what I am doing wrong? Thanks so much in advance!!!
#pragma strict
internal var animator : Animator;
var v : float;
var h : float;
var sprint : float;
function Start ()
{
animator = GetComponent(Animator);
}
function Update ()
{
v = Input.GetAxis("Vertical");
h = Input.GetAxis("Horizontal");
Sprinting();
}
function FixedUpdate ()
{
animator.SetFloat ("Jog", v);
animator.SetFloat ("Turn", h);
animator.SetFloat ("Sprint", sprint);
}
function Sprinting ()
{
if(Input.GetButton("Fire1"))
{
sprint = 0.2;
}
else
{
sprint = 0.0;
}
}