- Home /
Multiple input functions?
I'm having multiple problems lately one being - How would I be able to do an if statement with functionality when player press (W || S) and Fire1 Button to play the animation from W||S or up arrow key and down arrow key.
I want to make my player play the animation for "Fire1" only when the Up arrow Keyy, Down arrow Key and W, S key are NOT pressed.
Also I want a force to be added to my player once the "fire1" button is Up to move the player the direction he is facing. I did a code like -
if (Input.GetButtonUp("Fire1"))
{
animation.Stop("jump");
rigidbody.AddForce (100, 0, 0); }
How come no force is added to move my player?
Final question I have - How can I develop a script add focre to my player for length of time he is holding down the "w" key, but then stop once he reaches a max speed,but then slow down if pressing "s"?
Thank you so much!
Answer by Screenhog · Aug 15, 2012 at 08:35 PM
For your first question:
if (Input.GetButtonUp("Fire1")) {
if (Input.GetAxis("Vertical") == 0) {
//do something
}
}
This will make sure that something will only happen when you haven't pressed one of your vertical axis buttons.
Your answer
Follow this Question
Related Questions
2d Character physics? 1 Answer
Respawn script and door animation help 0 Answers
door animation physics 1 Answer
Way to have mulitple input? 1 Answer
play animation when moving,and idle animation when stand still 1 Answer