Spawn object random location, not near player

Get help using Construct 2

Post » Wed Sep 25, 2013 6:42 pm

So i've created a little zombie-like game.

Every time you kill a zombie there will spawn another one randomly at the map... There is one problem, A zombie can now spawn in the player or at one pixel from the player, making it an impossible game.

Does anybody know how to spawn an object at a random location, but not near another object?

Tnx
B
4
Posts: 14
Reputation: 228

Post » Wed Sep 25, 2013 6:50 pm

Put on a check for something like : When zombie spawns > if overlapping player > select new location
B
46
S
16
G
79
Posts: 2,170
Reputation: 46,857

Post » Wed Sep 25, 2013 6:59 pm

[QUOTE=plinkie] Put on a check for something like : When zombie spawns > if overlapping player > select new location[/QUOTE]

So something like this? (Sorry just started construct)



@plinkieIkBenHarm2013-09-25 19:03:49
B
4
Posts: 14
Reputation: 228

Post » Wed Sep 25, 2013 7:40 pm





Wish I could upload Capx, but here is an example of what you could do. Create an invisible spawn object that moves around randomly and spawns a zombie every five seconds or so. Also have an invisible player field pinned to the player, if the spawn overlaps that field then it moves else where to spawn the zombie. I am fairly new to construct myself but I did this when playing around and it worked for me!

Hope it helps otherwise I am sure someone else can get you something even better.
B
9
S
3
G
2
Posts: 51
Reputation: 1,522

Post » Wed Sep 25, 2013 7:59 pm

Kinda. That could loop properly. Would need to be tested. Also you'd need to delete the old one that was overlapping the player.
B
46
S
16
G
79
Posts: 2,170
Reputation: 46,857

Post » Wed Sep 25, 2013 8:33 pm

Okay, will check first in the morning, tnx!
B
4
Posts: 14
Reputation: 228


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, jobel, MeteoorSC, TRMG and 23 guests