I have 3 spawnpoint actors placed in the map, each should spawn only 1 actor ( a target dummy with hp that can die) .
How do i limit the spawner to spawn only 1 actor and how do i find out wich spawner currently has no spawned actor? so i can respawn them manually with a button click ?
Hey there @PGworlds! Welcome back to the community! Assuming you’re handling the spawning yourself, there’s a myriad of ways to go about this. A more beginner friendly method would be to just put a boolean on the spawner that it has spawned one already, and check that bool when you go to determine which spawn points are valid.
However, this scales poorly if you have to do it often or loop through many points. The proper way to do this would require learning about the Observer pattern. From a high level you’d basically have an array of valid spawners, and when a spawner fires it would remove itself from that list using an event dispatcher or directly if needed. Then you only need to update the list when a change is made and not have to constantly loop through the entire array every time.