How do I check if 2 objects are touching?

0 favourites
  • 5 posts
From the Asset Store
Surena Touch
$2.50 USD
A wrap from official Touch plugin to export touch/mouse input to other plugins.
  • I'm currently trying to make a platformer where the type of ground you step on determines your speed and acceleration. I'm having trouble being able to determine whether or not the player is on top of a ground. Notice that i want this to work even when the ground is not flat or horizontal. i know there is is a "Platform is on floor" event. Can i retrieve that floor instance or is there another easy way to do this?

    If it helps anything i know how to write javascript but never tried bridging it to construct.

  • juanfrancoc

    There's a few different ways to do it, depending on how you have your ground set up.

    Assuming you have different sprites for each ground type, one way would be to add Player is overlapping GroundSprite at offset (0,16) as a sub-event to the "Platform is on floor" event for each ground type and set speed/acceleration accordingly.

  • OddConfection

    I was thinking about this option as a last resource since it may cause problems with not horizontal grounds, however is one posible solution.

    It would be nice for future uses having a "Is touching" event. There could be something done with overlapping a slightly bigger hitbox

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I was thinking about this option as a last resource since it may cause problems with not horizontal grounds, however is one posible solution.

    It would be nice for future uses having a "Is touching" event. There could be something done with overlapping a slightly bigger hitbox

    Using is overlapping at offset to look directly below the player should work for any slope that the player can stand on, it's just a matter of how far below it you look, which is why I used 16 instead of 1.

    Also, the at offset version of is overlapping does away with the need for a bigger hitbox, with the offset essentially acting like extending the hitbox in a particular direction.

  • Also, the at offset version of is overlapping does away with the need for a bigger hitbox, with the offset essentially acting like extending the hitbox in a particular direction.

    Yes i understand that, however it fails to extend the hitbox in every direction. Moreover, it wont extend the hitbox, but rather move it, so if i have a small object and a big offset i could end up going over the object and not overlaping it at all.

    For now i think this solution will work though, at least for the scope im using here. Thank you very much for your advice,

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)