0 Favourites

How do I create coordinate exeptions?

  • this is my current situation.

    i have enemies spawning randomly around the player. however sometimes the enemies spawn ontop of the player or so close to it that it is imposseble to stop. how do i prevent this from happening?

    this is my current code.

    random(player.X+2000,player.X-2000)

    random(player.y+2000,player.y-2000)

    thanks

  • I think the problem is that your range includes the possibility for it to happen. Between +2000 and -2000 is your player. So, I thought that you might:

    • Could create imagepoints around the player in which the enemies would be spawned.

    • Could create a spawnable area, like a set of objects, and set them around the player in a way that they would not touch the player.

    • Set the enemy to spawn the way it is spawnning now, BUT if they are spawned near the player, they are destroyed and then spawned again until they get it right (for that you would create a box that will follow the player everywhere and if the enemy is spawned inside that box, that contains the player, the enemy is destroyed right away and then spawned again... for a better effect you should set them invisible and delay their visibility in a way that the player cannot see the enemies being destroyed by the box)

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • so i realy cant just create a hole in the spawn range. well thats a day wasted.

    thanks for awensering

    but at that point wouldnt it be easyer to create 4 diffrent spawnzones (its top down so thats why 4) and than make the time interval 4 times as large. if the spawn areas are large anouth the player wont notice that there are 4 things spawning at the same time.

    again thank you.

  • Sure you can do that. The last solution is the best one, but I think you would have to recode some of your stuff. For the hole in the spawn range, you could do it that way: https://sketch.io/render/sketch56d3817e5066c.png

    I think you already thought that, but just an illustrated way to create a hole in the spawn range.

    You are welcome. =]

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
99 10,136
karshinkoff's avatar
karshinkoff
Unread hot topic
56 4,728
MPPlantOfficial's avatar
MPPlantOfficial
Unread hot topic
0 Favourites
Why is Stencyl doing better?
44 16,852
Potato's avatar
Potato