- Home /
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!
Comment
This is so I do not have to disable a whole lot of objects.
Answer by FTheCloud · Aug 15, 2011 at 06:17 PM
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
}
}
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.