I want to play an animation if i push the key F
The name of the animation is 001
function Update() {
if(Input.GetKeyDown.F)
animation.Play(“001”);
}
please give me advice…
I want to play an animation if i push the key F
The name of the animation is 001
function Update() {
if(Input.GetKeyDown.F)
animation.Play(“001”);
}
please give me advice…
As you can see from the documentation, GetKeyDown does not inherit any values, such as GetKeyDown.F. It is a method, and it has to be passed parameters as the following link shows you:
http://unity3d.com/support/documentation/ScriptReference/Input.GetKeyDown.html
You can either pass in a string value, which is set in
Edit => Project Settings => Input
or you can pass in a KeyCode stated from the documentation as well:
http://unity3d.com/support/documentation/ScriptReference/30_search.html?q=keycode
So with that said, you have one of two options:
Input.GetKeyDown("Fire1"), Input.GetKeyDown("Fire2"), etc.
or
Input.GetKeyDown(KeyCode.F);
Obviously, you’ll most likely want to use the second override.