How to do something after x amount of shots fired?

So I am making an angry birds type game and the player will have 3 projectiles to choose to shoot. One of the mechanics I want a projectile to shoot is: When this projectile hits this block wait till after the player shoots 2 more times and then destroy the actor.

Now in my mind I am thinking ok I need to make a int variable that counts every time the player shoots, but after this part I get stuck on what to do or where to go from there. Now I may not even be on the right track of thinking lol but any help with this would be greatly appreciated :).

Thanks in advance! :smiley:

If you want to do something after the player has shot 3 times, no matter with which projectile, you probably should track the number of shots in the character/pawn or PlayerController.

If you want to do something after the player has shot 3 times with the same projectile, you could either keep track of the number of shots in a separate object for each projectile or in 3 separate int variables, one for each projectile type.

If you want to do something after the player has hit the same object 3 times (no matter with which projectile), keep track of the shots in the object that is getting hit.

If you want to do something after the player has hit the same object 3 times with the same projectile, use 3 different counters in the object that is getting hit.

Whichever you do, don’t increase the counter outright (e.g. using an Add node when the hit registers) but define a function which does that and that gets called when the shot is fired/object is hit. In this function, after increasing the counter, add a Branch check to compare the number of shots/hits, and if this is true, do whatever needs to be done, e.g. destroy the object.

I hope this helps you. Good luck!

So right now I do have the number of shots being tracked in my launcher blueprint and I would like to go about the first route the place where I get stuck is the last part. In my brain I don’t see how I can take an int that is always changing and say ok this just hit this so take that int and after it counts 2 more times do this. I am still a bit new to blueprint and I am probably just over thinking this lol.

So right now I do have the number of
shots being tracked in my launcher
blueprint and I would like to go about
the first route the place where I get
stuck is the last part. In my brain I
don’t see how I can take an int that
is always changing and say ok this
just hit this so take that int and
after it counts 2 more times do this.
I am still a bit new to blueprint and
I am probably just over thinking this
lol.

so you have an INT that stores number of shots?
lets say its called numShotsTotal

so right now you have

shotPressed > shot fired > increment numShotsTotal by 1
ya?

so now, create another INT, call it numShotsReset

so now you’ll want to have.

shotPressed > shot fired > increment numShotsTotal by 1 > increase numShotsReset by 1 > branch - does numShotsTotal=2? YES do crazy thing you want done AND after crazy thing is done SET numShotsReset to 0.

if branch is NO then do nothing.

now your second total will do the thing you want after x amount of shots (example is 2) then reset the count to 0 again so it will start over and repeat the next time it hits 2, while the main int continues counting up the overall shots.

So I am getting the logic down more but now its the final execution of it that I am having trouble with.

For example Now I am trying to say When this projectile hits this wall then resetShots fired to 0 and then when they == 2 destroy actor.

So far this is what I have come up with, but its not working.

So I got it working and this is what my blueprint looks like for anyone else that wants to do something along these lines. Thank you for all the help everyone! :smiley: