0 Favourites

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

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

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

    https://drive.google.com/uc?export=down ... EhIMXQ1N0E

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • 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)
Similar Topics Posts Views Last Post
Unread hot topic
0 Favourites
[plugin] Youtube player
175 20,543
rexrainbow's avatar
rexrainbow
Unread hot topic
99 10,139
karshinkoff's avatar
karshinkoff
Unread hot topic
102 6,404
Ashley's avatar
Ashley Construct Team Founder