How do I spawn objects but not if an object is already there

Get help using Construct 2

Post » Mon Jan 30, 2017 11:52 pm

I have an enemy that spawns randomly within a layer, but I have come across an issue. I have wall objects and I do not want the enemy to spawn inside or near them, is there some way I can set an event that will stop the enemy spawning inside the wall or near it, but keep the random placement I have?

Image
B
15
S
8
G
2
Posts: 68
Reputation: 2,465

Post » Mon Jan 30, 2017 11:58 pm

Enemy on created, if Enemy is overlapping wall, destroy Enemy, create Enemy at random(x,y)
B
47
S
18
G
84
Posts: 2,266
Reputation: 49,786

Post » Tue Jan 31, 2017 12:03 am

Would the enemy need to be on the same layer as the object? At the moment my enemy is on layer 1, the wall is on layer 0. I'm guessing this is why it hasn't been working for me?
B
15
S
8
G
2
Posts: 68
Reputation: 2,465

Post » Tue Jan 31, 2017 12:07 am

Nope, layer irrelevant, just if it's touching. Small chance it could be the collision boxes if it's not working, make sure the wall and the enemy have proper collision and that they intersect and that collision is enabled.
B
47
S
18
G
84
Posts: 2,266
Reputation: 49,786

Post » Tue Jan 31, 2017 12:26 am

I found the problem that was causing the issue. I had the enemy as a solid, which for some reason stopped the destroy event from working. Thanks @plinkie
B
15
S
8
G
2
Posts: 68
Reputation: 2,465


Return to How do I....?

Who is online

Users browsing this forum: SnipG, Yahoo [Bot] and 7 guests