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

Get help using Construct 2

### » Thu Dec 29, 2016 12:43 pm

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.
B
10
S
2
G
1
Posts: 49
Reputation: 693

### » Thu Dec 29, 2016 1:11 pm

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.

B
26
S
3
G
1
Posts: 480
Reputation: 2,290

### » Thu Dec 29, 2016 2:35 pm

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!

B
10
S
2
G
1
Posts: 49
Reputation: 693