Limiting The Number of Projectiles

I have used the First person shooter Blueprints and re modified for my own purpose.

What I’m finding difficult is the limiting the number of projectiles that can be on the screen for the player (I’m using the projectiles as a light source and then destroying them with a key input)

Is there a way to set a limit on the number of projectiles that the player spawns?

Hello, Mrfantasticghost.

If you want to limit the number of projectiles that can be onscreen - let’s say your limit is 10 - then I would just say that when there are already 10 projectiles on screen, the player is prevented from firing.

If you want to prevent the player from firing, I’d use a Branch on the blueprint before the projectile is fired (but after the ‘fire’ input is pressed), and check that the number of bullets onscreen* is less than 10 before firing. Otherwise, don’t fire. That should do what you want it to do.

*You would have to add a variable, maybe call it ‘BulletCount’, that increments when a projectile is created and decrements when a projectile is destroyed.

Regards,

Jonathan