Coll detect won't work when sprites solid?

For questions about using Classic.

Post » Mon Jul 30, 2012 6:08 am

Hello and thanks!

I'm a bit ashamed to ask for something that simple but it must be escaping me, I've been searching a long time and I don't know how to figure it out anymore; why aren't collision detections working when two sprites are flagged solid? All I have is;

On collision between Sprite1 and Sprite2
-> Destroy Sprite2

Sprite1 has the platformer behavior. I just want to hit a block with my head and destroy it. It works when one object is not flagged solid but that kind of defeats the purpose...

So in the meantime I placed a sensor on my character's head and all i'm using is overlapping detection, but that's a weird contraption when all I need is a collision detection from beneath the block.

I'm lighting a candle. Thanks a lot!
B
4
S
2
G
2
Posts: 108
Reputation: 1,366

Post » Mon Jul 30, 2012 7:05 am

Have you tried this in a fresh cap? I made a new project, added 2 sprites and one panel, set all 3 to solid, gave sprite 1 the platform behavior, panel placed below to stop sprite 1 from falling, and gave sprite 2 the mouse behavior.
+ Sprite: On collision between Sprite and Sprite2
-> Sprite2: Destroy

Worked. So I guess there must be something else that interferes with that event.
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Mon Jul 30, 2012 5:00 pm

I thought so too so I tried in a new .cap, it looks like I created it just like you (minus the mouse behavior) then again probably not, considering it is working on your side. :P

Have a look if you can;

http://dl.dropbox.com/u/38319441/CollisionTest2.cap

infinite thanks!
B
4
S
2
G
2
Posts: 108
Reputation: 1,366

Post » Mon Jul 30, 2012 6:51 pm

Weird, doesn't work for me either and I have no idea why
B
13
S
4
G
1
Posts: 63
Reputation: 1,170

Post » Mon Jul 30, 2012 7:11 pm

The platform behavior prevents any overlap with "Solid" objects. When the "on collision" event is run the objects are not overlapping so the actions are never run.
B
79
S
24
G
54
Posts: 4,746
Reputation: 40,755

Post » Mon Jul 30, 2012 7:39 pm

I tried your cap and it doesn't run the collision event. It did trigger in my setup, so I thought about it and this is what I've come up with.

If an object has the solid attribute than the platform object will never collide with it but stop right before the collision.
That's why it worked with the mouse behavior, I simply moved the solid object across that invisible border and the collision took place.

I'm not sure, how exactly you want your platformer to behave, but if it is simply a matter of "solid if floor, destroyable if ceiling", you could, for example, use this event in your example cap:
+ Sprite2: overlaps Sprite : offset (0,-1)
-> Sprite: Destroy

This will destroy the sprite only if Sprite2 overlaps with 1 pixel offset above (1 pixel offset is exactly what is missing, when the platform behavior stops the sprite because of a "solid" obstacle)

EDIT: *sigh* why is ROJO always beating me to it tulamide2012-07-30 19:40:01
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Mon Jul 30, 2012 7:52 pm

I'm glad it turned out to be a valid question after all! :D I'm gaining a little of my sanity back.

I never thought collisions were also based on overlapping. I thought that if I'm hitting a wall it was because it detected a collision.

Cool then, I'll investigate this overlap at offset action, it looks like a simpler way to compare positions. Also it's surely more reliable than my "sensor above the head" solution.

Thanks for the detailed help folks!


Gropwel2012-07-30 19:55:02
B
4
S
2
G
2
Posts: 108
Reputation: 1,366

Post » Tue Jul 31, 2012 12:12 am

[QUOTE=Gropwel]I never thought collisions were also based on overlapping. I thought that if I'm hitting a wall it was because it detected a collision.[/QUOTE] There are only two (but important) differences between "on collision" and "is overlapping".

- "On collison" only triggers once, no matter how long the objects collide, while "is overlapping" is true as long as they overlap.

- Different picking behavior.
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests