How to avoid the enemies spawn in a specific region

Bumpty

  • Posts: 14
So I make a game where somes ennemies spawn at random location, but I don't want them to spawn near the player.
So I create a Region that follow the player and I want the ennemies to not spawn on this region.
But I really don't know how, I try so many thing but ennemies always spawn near the player


Here is the behavriors to randomly spawn ennemies :


« Last Edit: August 01, 2013, 10:11:18 am by Bumpty »

flyingninja77

  • Posts: 30
You could do it a number of ways, but let's go with the one that's closest to what you've already got.  You created a region that follows the player.  Before you spawn your enemy, spawn a "test" actor that appears randomly on the screen.  If the actor does not appear in the region, then the area is safe and you can create the new enemy at the x/y of the test actor (and kill it).  But if the test does land in the region, kill the actor and try again.

t4u

  • Posts: 418
create attribute: x of spawner, y of spawner

set x of s(spawner) = random number
     y of s = random number

   while absolute value (x center of player - x of s) < (distance of safety zone) (probably= half        width of your region)
      set x of s = random number

  while absolute value (y center of player - y of s) < (distance of safety zone)
      set y of s = random number

create enemy at x of s, y of s
USE PICTURES WHEN YOU ASK SOMETHING!
If I helped you be sure to mention it in your game.

Tutorials + downloads:
http://t4upl.blogspot.com/