How do I cap the amount of targets that can spawn?


Should only be a max of 7 spawning at a time

looks expensive . What are you trying to achieve? Set your timer on beginplay not tick

I’m trying to make a game where the player shoots targets each one playing a different sound when its destroyed. I made an array that stores the 4 different targets but im having trouble spawning them at random positions for a certain amount of time being 2 mins

Some suggestions:

  • If they are going to keep spawning after destroyed, then rather than destroying / spawning, have that actor move to a random location.
  • On the actor that is managing the system (the spawner), rather than getting all actors of class bind the target OnDestroy event so that it knows when a target has been destroyed. It can then move it or spawn a new one.
  • I see there is an array for target class: if the difference is color or the static mesh comp, then perhaps only a single class is needed and the logic to randomize can be on the begin play of the actor?

I good points, also look at pooling.

This might be good solution for your case.