Bullet Fire: Steady Rate and too fast refresh
So I've been banging my head against this for a bit. I'm trying to get a set up for a character that uses bullets, but only so many can be out at a time.
The idea is to make a setup that when you hold down the fire button, it immediately fires a shot then fires in a steady rate after that. Since Every loops would wait before the first shot, which is a bad set up, ive been trying to get around it. The problem is, the way i have it set up now, if the max number of shots are on screen and then one despawns, no matter where it is on the timer the player INSTANTLY fires another one. If they get close to a wall, they immediately override the loop and just fire as fast as the shots cycle.
Here's the pertinent code. The minimized timer is an Every loop, unchecked "to completion" with the same two commands as the ones you can see inside, to create the continuous fire.The trigger to add a shot back to the projectile max is on the shot itself right as it is destroyed. I fear this is an issue of the projectile max going from 1 to 0 and back up to 1 retriggering the event but i cant find another way to put this together that im satisfied with it. Note, there is an outside wrapper boolean rule for Shots Fired that controls the animation frames for this character, that all of this is enclosed in. THAT has a .15 second timer before it goes false and the animations reset when the shot button is released.
Comments
Sorry to bump this, but I am REALLY stumped here, and cannot figure out a good conclusion. I tried tiying it to the mentioned Wrapper boolean, but since that has a delay in shutting off, it means that if you hammer the button, the shot never fires and the animation just stays on. I tried putting it just on the button input without the Bullet number attached, but that destroyed the ability to keep the number of shots limited. I just dont know what angle to approach this from.
I don't quite understand what the problem is.
"if the max number of shots are on screen and then one despawns, no matter where it is on the timer the player INSTANTLY fires another one"
I don't understand this sentence. I made a very similar firing button and it works.
The problem is that i want the shots to fire steadily if the player holds the button down, at a rate not determined by the destruction of the shots already on screen. But that is the determining factor. So if, say, the player gets close to an enemy, since the shots despawn so fast, a steady rate of fire turns into a machine gun for no reason.
What is the value in the timer below? You should set it to the fire rate you want, like, ever 0.6 seconds.
Also, by that setup, player can rapidly tap the button to fire rapidly. To stop that, you can create a boolean in the actor like self.amIReadyToShoot and you can create a rule like this inside the main rule;
The timer is fine, its the overriding by rapid tapping that i dont like. I guess adding another boolean is the only sensible option. Thanks.
Yeah you can't do it without another bool I guess. If someone comes up with a better solution I got 2 games I'd like to use it
Honestly, Im starting to feel overloaded with booleans. Its amazing how quickly they multiply in behaviors.
But your setup works great. So thanks for the help!