How do I allow an enemy to spawn anywhere but player's x &y

Get help using Construct 2

Post » Sat Feb 21, 2015 4:06 am

I'm trying to make an event so that an enemy may spawn anywhere on the map except the player's current X any Y position but i'm not sure how to. Can anybody help me? Thanks in advance!
B
12
S
3
Posts: 129
Reputation: 1,131

Post » Sat Feb 21, 2015 4:54 am

use a function to spawn the enemy, then , after the spawning action, check for the position... if its teh same of the player call the function again.....

the loop will continue until the spawned enemy is not on the same position than the player
Image
B
46
S
12
G
6
Posts: 270
Reputation: 11,616

Post » Sat Feb 21, 2015 5:58 am

Something like this?

System: Random(1) = 1
create object at player.x+100+random(1000)

Else
create object at player.x-(100+random(1000))

and same for y
B
16
S
7
Posts: 301
Reputation: 2,686

Post » Sat Feb 21, 2015 9:18 am

edit : nah, I made a mistake :D
B
12
S
7
G
7
Posts: 447
Reputation: 4,270


Return to How do I....?

Who is online

Users browsing this forum: CJacobsSA and 16 guests