How do I check on which side something collided with player?

0 favourites
  • 3 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • Hi,

    I'm making a little platformer using the Platformer behavior for my player character. What I'm noticing is that there's no clear way to discern if something is hitting my player from a certain side.

    I've been using a check of the player.X or Y with that of the colliding object so far. Combined with a check if the player is falling, jumping, etc. (conditions provided by the Platformer behavior) this method gives a good approximation of the direction of collision.

    This solution is not perfect, however. If the player is falling, using this player.Y<object.X as a condition will trigger for a collision on the side as well as the top of the object. Hitting it perfectly on the side while falling, with the player.Y<object.X, doesn't happen very often but it does happen.

    What I'm looking for is another method to detect which side of the player's collision box is touched by static/non-static objects. My player's collision is always a rectangular shape.

    Any help is greatly appreciated.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Do you use 'Is by wall' from the Plattform-Behavior? Wouldn't that be easier than to check for x and y coordinates?

    However, I made something with ' is overlapping by offset'. Maybe it's helpful for you. I shows where the sprite has its collision. ... EhIMXQ1N0E

  • The overlap example didn't work out for me, because I want the collision to be pixel perfect and I like to work with power of two sized sprites.

    But... your is-by-wall idea did inspire me to adapt your .capx and write some excluding conditions that seem to the trick. I've been trying out every possible collision and each time the correct side is chosen.

    So thanks for the help!

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