- Home /
Play animation when 2 keys pressed?
i thought it would be:
{
if(Input.GetButton("w") && Input.GetButtonDown("space") {
animation.Play("JumpOver")
}
}
but that does not appear to work :/ any ideas?
Answer by Karl Negm · Aug 21, 2013 at 08:08 PM
This is a walk script that i made #pragma strict
function Start () {
}
function Update () {
if (Input.GetKey(KeyCode.W))
animation.Play("Walk");
if (Input.GetKey(KeyCode.LeftShift) && Input.GetKey(KeyCode.W))
animation.Play("Sprint");
}
this shall Help
Answer by Piflik · Jan 04, 2013 at 09:47 PM
Theoretically this is should be working, but there are two issues:
You're using GetButton/GetButtonDown, so you need to use buttons defined in the Input Manager
You are using GetButtonDown in one of them and that is only true for one frame. You would have to make sure, that you press 'w' first and 'space' second.
I get these errors:
(2,1): BCE0043: Unexpected token: if.
(4,32): BCE0044: expecting :, found '}'.
Answer by SahilBhilave · Apr 17, 2015 at 07:49 AM
if(Input.GetButton("w") && Input.GetButtonDown("space")) { animation.Play("JumpOver") }
//Add a bracket after space
Your answer
Follow this Question
Related Questions
how to play two animations simultaneously in c#? 1 Answer
how to play another animation on different object after the first one 1 Answer
how to make a animation play only if you press a certain key? 8 Answers
How to play two animations simultaneously one after another ? 0 Answers
Play animation in child model 0 Answers