` var Playerstate : float; var PlayerAnimSec : GameObject; function Update () ) PlayerStateController(); PlayerAnims(); ) function PlayerStateController() ( if ((input.GetAxis("Vertical")!=0 ||input.Get Axis("Horizontal")!=0) ( if (input.Getbutton("Sprint")) ( Playerstate = 2; ) else ( Playerstate = 1; ) ) else ( Playerstate = 0; ) ) function PlayerAnims() ( if (Playerstate == 0) ( PlayerAnimSec.animation.CrossFade("Idle Animation", 0.4); ) ( else if (Playerstate == 1) ( PlayerAnimSec.animation.CrossFade("Walking Animation", 0.4); ) else if (Playerstate == 2) ( PlayerAnimSec.animation.CrossFade("Sprint Animation", 0.4); ) `
Try this, and maybe look for some documentation online.
var Playerstate : float;
var PlayerAnimSec : GameObject;
function Update ()
{
PlayerStateController();
PlayerAnims();
}
function PlayerStateController()
{
if ((input.GetAxis("Vertical")!=0 ||input.Get Axis("Horizontal")!=0)
{
if (input.Getbutton("Sprint"))
{
Playerstate = 2;
}
else
{
Playerstate = 1;
}
}
else
{
Playerstate = 0;
}
}
function PlayerAnims()
{
if (Playerstate == 0)
{
PlayerAnimSec.animation.CrossFade("Idle Animation", 0.4);
}
else if (Playerstate == 1)
{
PlayerAnimSec.animation.CrossFade("Walking Animation", 0.4);
}
else if (Playerstate == 2)
{
PlayerAnimSec.animation.CrossFade("Sprint Animation", 0.4);
}
}
EDIT:
Changed your script a little bit more, but I did not test it, so if there are any problems, just comment.