x


Disable, Enable a User Input?

Is there any way I can disable an input? For example, my character reloads, if you try to fire the input is rejected. Then when the animation is finished, enable the input.


What should happen -
Press R
animation starts reload
disable left mouse button click input
animation finishes
enable left button click.

Please help!

more ▼

asked Aug 15 '11 at 06:09 PM

cronixgames gravatar image

cronixgames
-2 7 11 11

This is so I do not have to disable a whole lot of objects.

Aug 15 '11 at 06:10 PM cronixgames
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Just an example:

var reloadTime : float = 1.0;
private var nextFireTime = 0.0;

function Whatever () {
     if (Input.GetMouseButtonDown(0) && Time.time > nextFireTime) {
            nextFireTime = Time.time + reloadTime;
    //Fire bullet do Whatever
    }
    }
more ▼

answered Aug 15 '11 at 06:17 PM

FTheCloud gravatar image

FTheCloud
735 15 20 27

It doesn't look like it disables then enables

Aug 15 '11 at 06:28 PM cronixgames

It doesn't. In your example you mentioned reloading so I assume that's what you asked your question for. So this is how you'd do it. It's up to you to correctly implement this into your script.

Aug 16 '11 at 02:12 AM FTheCloud
(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:

x983
x953
x215
x133
x38

asked: Aug 15 '11 at 06:09 PM

Seen: 1852 times

Last Updated: Aug 16 '11 at 02:12 AM