Has anyone do use raycasts for collision detection?

I am trying to do simple 2d platformer prototype using raycasts for collision detection. But stuck at handling slopes and moving platforms. Finally i give up. I am start thinking, this is impossible using current raycasts implementation.
For slopes, I should cast vertical rays with respect to horizontal player movement, i can do this only after i get horizontal hit results. But i can’t because of async raycast in Defold.
For moving platforms, i should move player in some circumstances before i move platform. But i can’t because there is no response when nothing is hit.

Plus, we get only closest hit from the starting point.

Raycasts in Defold is almost useless.

Raycasts are not useless, but you are trying to use them to solve a problem where there are much better solutions. It’s like trying to use a screwdriver to hammer a nail or something.

3 Likes

There are many ways to solve this - depending on how your game mechanics and environment looks. I have done slope handling with ray casts without problems. They are certainly not useless.

1 Like