How do I create coordinate exeptions?

Get help using Construct 2

Post » Sun Feb 28, 2016 4:47 pm

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
B
2
Posts: 2
Reputation: 154

Post » Sun Feb 28, 2016 5:00 pm

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)
B
7
S
2
G
1
Posts: 38
Reputation: 917

Post » Sun Feb 28, 2016 5:12 pm

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.
B
2
Posts: 2
Reputation: 154

Post » Sun Feb 28, 2016 11:25 pm

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. =]
B
7
S
2
G
1
Posts: 38
Reputation: 917


Return to How do I....?

Who is online

Users browsing this forum: ALLMarkMade and 22 guests