How do I get the distance between the player and the nearest platform right under it?

How do I get the distance between the player and the nearest platform right under it?

The simplest way, please.
Thanks in advance.

You could use the Raycast condition.
Then you’ll get the X and Y position of where the Raycast will stop
after that you can calculate the Distance Between the player and the X and Y of the Raycast’s last position

1 Like

For the Object to test against the ray, I create a group with all the platform objects in it. One is out if it looses the platform behavior, and gets in if it gets it.
The testing object is this group.
right?

I don’t fully understand how to use the Raycast thing.

I think you can use groups
If you want a Raycast to work all you need to do is to specify the object the ray is looking for (your group in this instance), the starting X and Y of the ray (which would be the X and Y position of the player), the angle of the ray (180) and then you can store the X position and Y position as scene variables (Variable())

1 Like

Thank you very much!

By the way, you can use the Shape Painter object to draw your Raycast so you can see where it is
you would draw a line going from the player X and player Y and ending at the X and Y of the raycast’s end
also you should use the player’s CenterX and CenterY to make sure the ray gets casted properly

1 Like