I need to make a variable for the amount of enemies in the level

I need to make a variable for the amount of enemies in my level, the enemies spawn endlessly in a bounding box using an integer in a random range. This is why I can not just add X amount of enemies to the variable each spawn. Does anyone know how I can use the random number the engine picks as the number to add to the variable?

I am using blueprints to make the game.

Any help would be greatly appreciated.

Hi man your question is not fully clear so if i misunderstood , just rewrite your question more clearly.

You have a box , in wich you want to spawn endlessy a number N of monsters.
N is a random number in a range.
Like spawn every 10 seconds 2-5 ghost

So you should build up a function or a event “Spawn enemies”
the first thing is set your number of enemies, so take the "random int in range " node and calculate with some literal values or variables, the right amount of enemies you want to spawn.
Lets say i am at level 3 , so i want to spawn at least 1 ghost for lever and max 3 ghost for level of difficult.
Once you have completed the random in range you can use his output as number of iteration in loop.
Take the loop node and pin in the last index.
Now in the loop body build up your spawning .
be carefull that spawn all ghost in same location may cause troumble.

Hope this help :slight_smile:

Thanks for your help but I have already got the enemies spawning but I want to control the amount that can be in the level at a given time.

The blueprint I created spawns between 2 and 6 enemies so I want to add the number the engine picks to a variable each time a group is spawned because it is random I can not just add X amount to variable each time it they are spawned,

If I could get the variable to see the number the engine is picking and add that to the current number of enemies variable I will be able to use a branch to stop the spawn when 50 enemies are in the level.

Oooo…
Maybe i get it now , You want know how many enemies you have already spawned to stop spawning?
There is a node called “get all actor for class” or “get all actor with tag”.
These will give you an array ,with all the “enemies” you just get his “lenght” .
So IF ( get all actor of class “Monsters” )Lenght is < of 50 , SPawn monsters otherwise, not spawn.