My script should make it so I can play the running animation and shoot or idle and shoot but after I reload the shoot animation wont play anymore. Please help. There is no error.
Here is my script:
#pragma strict
var bullets : int;
var runAnimPlaying : boolean;
function Start()
{
bullets = 10;
runAnimPlaying = false;
}
function Update ()
{
if(Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.D))
{
runAnimPlaying = true;
}
if(Input.GetKeyUp(KeyCode.W) || Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.D))
{
runAnimPlaying = false;
}
if (runAnimPlaying == true)
{
animation.CrossFade("Run");
}
if(bullets > 0 && Input.GetMouseButtonDown(0))
{
bullets -= 1;
animation.Stop("Run");
animation.Stop("Idle");
animation.Play("Shoot");
}
if(Input.anyKey == false)
{
animation.CrossFade("Idle");
}
}
function ReloadGun()
{
yield WaitForSeconds (0.8);
bullets = 10;
}