Hi
I found this scipt from another answer
var walking = false;
function Update () {
if (Input.GetAxis("Vertical") > 0.2 && !walking) {
animation.CrossFade ("walk");
walking = true;
}
if (Input.GetAxis("Vertical") <= 0.2 && walking) {
animation.CrossFade ("idle");
walking = false;
}
}
I am trying to add 3 attacks in this script so they play the animation how would i do that like shoot and throw granade and play animation for pickup each time i try to change it but it messes up my animation. I want it to be able to play grenade throw animation when i press 1 and pickup item by 2 and mouse click to play the animation for shoot this was one my try on trying to get this work
var running= false;
var shoot= false;
var idle = true;
var pickallow;
var throwing= false;
function Update ()
{
if (Input.GetAxis("Vertical") > 0.2 && !running)
{
animation.CrossFade ("run");
running = true;
shoot = false;
idle = false;
}
if (Input.GetAxis("Vertical") <= 0.2 && running)
{ animation.CrossFade ("idle");
running = false;
shoot = false;
idle = true;
}
if (Input.GetAxis("Vertical") <= 0.2 && "fire1")
{
animation.CrossFade ("shoot");
shoot = true;
running = false;
idle = false;
}
if (Input.GetAxis("Vertical") <= 0.2 && Input.GetKeyDown( "1") == true)
{
animation.CrossFade ("throw");
throwing = true;
running = false;
idle = false;
shoot = false;
}
}
please help thanks