How to check if max barrels are spawned, then stop event and start again if 1 Barrel gets picked up.

I have a spawn barrel event which spawns Barrels in 2 rows with 3 colums. I created a Interaction pickup event and now I want to check if max barrels (6) are spawned, then stop event and start again if 1 Barrel gets picked up. I would appreciate any help. Thanks . Here is the code for the SpawnBarrel Event.@ClockworkOcean

If these are the only 6 barrels, you could do a ‘Get All Actors Of Class’ for the barrels, then get the length of the Out Actors array and if it’s less than 6, respawn.

You could also simply respawn in the interaction pickup event.

Imo. You’ll find yourself adding conditions to make this work when scaling.

Some quick ideas:

  • Create an actor that spawns the barrels. Listen to the EndOverlap or OnDestroyed event of the barrels to start a timer. This actor could be spawned by the catapult, for example.

  • Handle all the logic in a component that dynamically listens to the overlaps it spawns.


–-

I can share a simple BP if you need it.

If u could share a simple BP that would be awsome. Thanks for the help

Every time a barrel is picked up you need to notify the barrel spawner.

How can I do that? Sorry Im new to ue5

I’m going to assume the server is handling the pickup, spawn and is tracking the count.
When you spawn a barrel you increment an int.
When you take a barrel, you decrement the int. So you continue that chain.

-1, spawn 1