Spawn Overlap Problem

Get help using Construct 2

Post » Mon Feb 11, 2013 8:57 am

Hi folks

Having an issue with spawning multiple instances of the same object. My sprite is 32*32 with an image point at 49,16 (where it spawns its child).

Basically, I don't want to spawn a new child if one of its brethren is in the way. So I tried this:



Specifically, I though the "Mob X Overlapping" would stop it spawning on top of an existing instance. Unfortunately, I was wrong.

Is it not possible to do this? Should I pin another sprite so I can check for overlap on that instead? Or have I just done something daft.

Thanks in advance for any help.
B
5
Posts: 19
Reputation: 363

Post » Mon Feb 11, 2013 9:09 am

Make your 'not overlapping" condition like this:

Not overlapping Mob at offset (Mob.imagepointX(1), Mob.ImagepointY(1))

This condition checks if there is overlapping mob at location of the designated imagepoint.

I am assuming that imagepoint you are checking for is imagepoint 1. Imagepoint 0 should always be your objects origin :)
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Mon Feb 11, 2013 9:18 am

Thanks for the feedback vee.

That's much more efficient than messing about with maths. However, they still spawn on top of each other. Am using imagepoint 1.
B
5
Posts: 19
Reputation: 363

Post » Mon Feb 11, 2013 9:20 am

[QUOTE=Superelastic] Thanks for the feedback vee.

That's much more efficient than messing about with maths. However, they still spawn on top of each other. Am using imagepoint 1.[/QUOTE]

Then you should check that your sprites collision polygon is properly set. Posting a .capx of your problem would also make it easier to see what is the cause for that :)
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Mon Feb 11, 2013 9:29 am

Haven't tried sharing a non image file on here.....

https://www.dropbox.com/s/mi3awr2r9o9kzaj/Alife2.capx

Let's see if that works.

Be warned, you may find my programming painfully naive.
B
5
Posts: 19
Reputation: 363

Post » Mon Feb 11, 2013 10:29 am

My bad, the formula for checking overlap would actually be:

Mob.ImagePointX(1) - Mob.X
Mob.ImagePointY(1) - Mob.Y

as it's offset from the object and not direct location coordinates :)

Anyway, seems there is another problem when checking for overlaps from same objects, couldn't quite understand why. Probably someone else can shed some light on this? Does it perhaps have something to do with picking, like both of the objects are picked when checking for overlap and something weird happens?

One way to go around this would be to add 'mob' into a family and check if there is overlap with that family. Not the most elegant way but seems to work.
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Mon Feb 11, 2013 10:42 am

Thanks again, vee. I'll have a go at using families.
B
5
Posts: 19
Reputation: 363

Post » Mon Feb 11, 2013 11:22 pm

Indeed, only solved by sticking Mobs in a family.
B
5
Posts: 19
Reputation: 363


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 22 guests