How can i know which side of the player is colliding with the tile?

I’m trying to make a parcour and i need to know which side of the player is colliding during the collision so that i can use that information to define where to create the particle emitter. For example, if player collides with the parcour with its right side the particle emitter object should be created at that position, to give the feeling of smashing into a wall at high speed.

You could try putting a point on the front of the player, and if that point is in the collision object, check if the player is flipped

You can compare the x position of the player and the object collided with. player.x < object.x, left side collision. player.y > object.y, right side collision.

I tried this before. I put two symmetrical points on the right and left side of the player and tried to calculate which point is closer to the wall. But because of i say “tiles” as group in events, it doesn’t know which specific tile it is. So it can’t calculate the distance.

How can i check if a point is in collision?

No, check the centre point of the player. If you use the condition “Player in collision with TileGroup”, only the tile the player collides with will be referenced in the actions and any subevents.

So you can do the following to get the collision with a tile:


I tried soemthing like this but regardless of which side of it hits, it creates the particle emitter on the right side every time.

Here is what i did:

These are the conditions that compares the distance of the point on the right side and the left side to the centerX of the tile:

And this is how it calculates the distance:

Am i doing something wrong? Are there any tricks that i don’t know?

In your last pic, it has CenterX() twice, it should be CenterX() and CenterY()

Did you try comparing the centerX() values of both objects like previously suggested. You wouldn’t need the additional variables and calculations.

Yes i tried the previous one and it didn’t work.

This is how my game looks like. The player tries to complete the parcour as fast as possible using the joystick. As you can see from the picture, the direction of the player changes consistently. So comparing the CenterX values of both objects may not work here since the player can go both upways and sideways .

So its a bit more complex and i don’t know how i will make it work. So now i’m giving you this picture to help you better.

That’s a completely different issue. I think we just assumed the walls were vertical.

1 Like

I think I found a simple way to do it. At least with a circle and rectangle. You cast a ray in a 90-degree angle from the rotation of the wall. I can’t figure out an easy way to tell which side you’re on. So, I simply casted 2 rays. I used a distance of 100. That might need to be tweaked.

The ends are also a challenge. IDK how to tell if you’re touching an end.

The circle is draggable. This draws the point but it could easily be used to add a particle emitter.

1 Like

To check all sides, you just need to check the other directions. I simplified it and made it plus 0, 90, 180, 270

The circle is draggable. This draws the point but it could easily be used to add a particle emitter.

1 Like

OMG bro it worked. I just have push it against the wall a bit harsher but i think it has something to do with my collisions and i can easily fix it.

Anyways thank you so much to everyone for your efforts, it’s so amazing that the world is full of geniuses like you guys:)

1 Like