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.
Develop games in your browser. Powerful, performant & highly capable.
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
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!