x


Input.GetButtonUp ?

I want to press a button and detect if this has happened as soon as I pressed the button. These functions only detect a key press if I release the button and both seem to be the same?

Input.GetButtonUp or Input.GetButtonDown

void Update () {
      if (Input.GetButtonDown("Jump"))         
    {
       Debug.Log("Space bar pressed");
    }



}
more ▼

asked Jun 04 '12 at 02:13 AM

jagguy gravatar image

jagguy
30 6 26 36

I have no idea what are you asking.

Jun 04 '12 at 02:20 AM Jessy

GetButtonDown only returns true during the frame when the button is pressed down. GetButtonUp only returns true during the frame when the button, which had previously been pressed, is released.

Jun 04 '12 at 02:23 AM Eric5h5

I think you're going for unity answer a bit too fast. Try to figure it out by yourself first. Most of your questions are simple.

Jun 04 '12 at 02:26 AM Berenger

ok this works thanks but how do I get this to work for anykey like 'a' or 'b' or arrow keys?

Jun 04 '12 at 02:32 AM jagguy

Read the input manager docs.

Jun 04 '12 at 02:38 AM Eric5h5
(comments are locked)
10|3000 characters needed characters left

1 answer: sort oldest

GetButtonDown only returns true during the frame when the button is pressed down. GetButtonUp only returns true during the frame when the button, which had previously been pressed, is released.

more ▼

answered Jun 04 '12 at 02:33 AM

jagguy gravatar image

jagguy
30 6 26 36

(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:

x55

asked: Jun 04 '12 at 02:13 AM

Seen: 623 times

Last Updated: Jun 04 '12 at 02:58 AM