I have a robot with a few simple animations There are moments when it is performing an operation and I want to lock the controls so the animation can not be interrupted. How would I do this?
Are all of your game controls in a single Update() function? If so you just:
var isLockdown:boolean = false;
Update(){
if (!isLockdown){
// Do your input here
}
}
And turn isLockdown to true when you want the controls locked. If your controls are scattered all over your code, you'll have to do a (!isLockdown) check in each place...
I would normally use coroutines for this:
function Start () {
while (true) {
if (Input.GetButtonDown("Jump")) {
yield Jump();
}
yield;
}
}
This way the input isn't checked at all while the Jump coroutine is running.
Thank you both.
Eric5h5: I don't understand the "yield jump()" comment. Its the "jump" referring to the jump
button? If it is, what would lock out everything?</p>
I plugged your script in and I am not getting anything to stop. While I couldn't
figure out the Jump(), I plugged in the "WaitForSeconds(5) to see if I got any stop
and still nothing.