How Do I Spawn Actors Without Spawning Them on Top of Each Other?

I have one spawner spawning actors at the same x coordinate at a random(50,220) y coordinate that move off to the right off the screen. It's spawning them correctly but sometimes the actors will spawn on top of each other, especially later on throughout the game where it is spawning an actor every 1-3 seconds. How do I make a rule that says it will not spawn an actor close to another actor?
Best Answer
-
JohnPapiomitis Posts: 6,256
Also make sure to have the spawn behavior above the destroy behavior in that rule. Or else it wont spawn another since itll be destroyed first.
Answers
If self.time < .15 (If the time its been alive is less then .15 seconds)
and
colliding with spawned_actor (the enemy or whatever you're spawning)
Then Destroy Actor
Spawn Actor (With same parameters as before: x coordinate random(50,220))
You might also be able to make the time less, to .1 although You need to make sure the entire "If" statement can be processed in the time that you have set. Hope this works!
EDIT: Found a problem. They'll spawn and quickly go away, still enough for the eye to catch. Here is a way to solve that.
Start them with alpha at 0 (0% opacity) and set that as the original color. Then make this:
If (ORIGINAL HERE)
Then (Do original. Destroy and Spawn another.)
Otherwise (Change Self.Color.Alpha to 1)
This should make them not blink.
EDIT 2: No matter how many more attributes or things I try, they seem to always blink or bounce around. Don't try anything I've suggested :P