x


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!

more ▼

asked Aug 11 '12 at 08:10 AM

SoloGameProject gravatar image

SoloGameProject
-5 2 4

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Aug 15 '12 at 08:35 PM

Screenhog gravatar image

Screenhog
1.5k 5 11 20

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3934
x3419
x1948

asked: Aug 11 '12 at 08:10 AM

Seen: 247 times

Last Updated: Aug 15 '12 at 08:35 PM