x


Detect Button Being Held Down

I want to detect if I have the F Key held down for 0.5 seconds, to call the function PickUp();

more ▼

asked May 11 '11 at 03:24 AM

Fierce Waffle gravatar image

Fierce Waffle
176 34 38 49

I guess there is no way to stop such kind of simple question in UnityAnswers.

May 11 '11 at 03:34 AM Dreamer
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first
var count:float=0.5;

function Update () {
if (Input.GetKeyDown ("f")){
  count-=time.deltaTime;
  if(count<0){
  PickUp();
  count=0.5;
  }
}
else
   count=0.5;
}
more ▼

answered May 11 '11 at 03:32 AM

Dreamer gravatar image

Dreamer
1.5k 39 49 66

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

x790
x49
x32

asked: May 11 '11 at 03:24 AM

Seen: 3485 times

Last Updated: May 11 '11 at 03:24 AM