- Home /
script for animation play
Hi!! Im learning scripting slowly and I'm trying to make a reload script from scratch! but for right now I just want the animation. I have the animation, (gun_reload) but my script is not quite right. can some one give some pointers?? here is my script.
function Update () { if(Input.GetButtonDown("reload")) animation.Play("gun_reload"); }
but I dont know what to put between the ("reload")) and animation.Play to play the animation every time the reload button (r) is hit? P.S. I have the button set up correct. thanks for your time
Answer by nhftk12 · May 28, 2011 at 01:53 PM
You wrote "(Input.GetButtonDown("reload"), that your problem. You need to write this:
if (Input.GetKeyDown("r"))
{
animation.Play("gun_reload");
}
In GetButtonDown you can't use all the key on the keyboard, you can use buttons like "Jump" or "Vertical", "reload" in not include in that group. If you want to use any key on your keyboard you need to use GetKeyDown, it allow you to use all the keys on you keyboard.
Sorry for poor english...
That is only partionally true. He properly just went into the Input$$anonymous$$anager to setup the "reload" button. As he said:
"I have the button set up correct. thanks for your time".
You right... I didn't see it... But what I sade is true, he can use it.