I have a little game I am working on, and I ran into a small issue. When i do a weapon swap, an animation plays of the gun coming out of the bottom of the screen, but you can still shoot while you are not supposed to. What a player can do is immediately swap between a sniper and a secondary and the sniper will be able to shoot as fast as a rifle. How can I have a property set to 1 when a certain animation is going on and set to 0 when the certain animation is completed?
You can do this somewhat easily by using a logic setup similar to this.
It basically works by having your button that triggers the weapon change (in this case we are using X) assign a Boolean property
Playing Animation? to be true.
When this property is true, it adds to the
frame property. This plays the animation. once this is working, it is fairly easy to make it so that it will Not fire when the animation is playing. To do this simply have a property sensor detect when the Boolean
Playing Animation? is false. When it is false, you can press Spacebar (or any other key) and it will shoot your projectile.
This can be seen here. When the animation is playing it will not shoot the plasma blasts. (it is a jump animation here, but it could be anything, that includes a weapon reloading)
If we shorten the delay between pulses for the keyboard sensor, the plasma coil will fire faster.