How to avoid actors spawning on top of other actors

I am developing a game where an actor is randomly spawned somewhere the screen every couple of seconds. The problem is that because the place where the actor spawns inside the screen is determined randomly, sometimes the new version of the actors appears on top of the old version of the actor that is still present in the screen (the old one hasn't been eliminated yet by the player)
Is there a way to avoid actors spawning on top of each other while still maintaining the random element of the game? (meaning the player doesn't know what part of the screen the actor is going to spawn)

Thanks

Answers

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
    I think you could check for a collision when it spawns, and if it collides with another actor, destroy it and spawn it at a new location.
  • VW_GamesVW_Games Member Posts: 31
    Thats what i did for on of my games
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited November 2013
    I also used @jamie_c's solution. Is there a reason you don't like that idea? Have you tried it?
Sign In or Register to comment.