Coll detect won't work when sprites solid?

This forum is currently in read-only mode.
From the Asset Store
Check preview, download and add value to your games.
  • 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!

  • 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.

  • 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;

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

    infinite thanks!

  • Weird, doesn't work for me either and I have no idea why <img src="smileys/smiley11.gif" border="0" align="middle" />

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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 <img src="smileys/smiley36.gif" border="0" align="middle" />

  • 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!

  • 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.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.
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)