1
$\begingroup$

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?

$\endgroup$

1 Answer 1

5
$\begingroup$

You can do this somewhat easily by using a logic setup similar to this. enter image description here

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)

enter image description here

If we shorten the delay between pulses for the keyboard sensor, the plasma coil will fire faster.

enter image description here

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .