Box-Shaped Raycast equivalent in BabylonJS

Hello,

I am currently working on a basic First Person Controller along with some additional features such as jumping.
For the jumping mechanism I need to detect whether my player mesh is touching the ground or not.

A simple raycast, as seen in the image, does not suffice for me as this does not really allow me to walk up ramps:

The raycast does not detect that I am on top of a surface, hence why it thinks I am in the air, and thus apply air movement.

Now, to my actual question:
In Unity, to handle ground detection, you can use a “BoxCast” (Unity - Scripting API: Physics.BoxCast) to detect ground collision. Basically it performs a box-shaped raycast in the desired direction.
I’ve been looking through the BabylonJS docs and have not found anything similar to this sadly.

How would you be able to perform the equivalent of a box-shaped raycast in BabylonJS?
Any ideas are welcome.

1 Like

Hello and welcome abroad!
We have plans to enable this with the Havok physics engine: [Physics] Check intersection with Shapes · Issue #13873 · BabylonJS/Babylon.js (github.com), but it’s not started yet. Until then, maybe you can try a triangle-box intersection algorithm? AABB-Triangle · 3DCollisions (gitbooks.io)

1 Like

Try to search the forum about this problem, I think there have been some posts on the subject.

For eg:

1 Like