# Box-Shaped Raycast equivalent in BabylonJS

**URL:** <https://forum.babylonjs.com/t/box-shaped-raycast-equivalent-in-babylonjs/43190>\
**Category:** Questions\
**Tags:** ray\
**Created:** [August 10, 2023, 3:02pm UTC](https://forum.babylonjs.com/t/box-shaped-raycast-equivalent-in-babylonjs/43190 "2023-08-10T15:02:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![DukeVen](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dukeven/32/34217_2.png) [@DukeVen](https://forum.babylonjs.com/u/DukeVen)\
**Post date:** [August 10, 2023, 3:02pm UTC](https://forum.babylonjs.com/t/box-shaped-raycast-equivalent-in-babylonjs/43190/1 "2023-08-10T15:02:11Z")

</div>

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:

 ![raycast](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/6/c/6c3a3a52f5fa6def660a4bc2c0341c48f37758ab.png)

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](https://docs.unity3d.com/ScriptReference/Physics.BoxCast.html)) 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.

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [August 10, 2023, 8:46pm UTC](https://forum.babylonjs.com/t/box-shaped-raycast-equivalent-in-babylonjs/43190/2 "2023-08-10T20:46:02Z")

</div>

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)](https://github.com/BabylonJS/Babylon.js/issues/13873), but it’s not started yet. Until then, maybe you can try a triangle-box intersection algorithm? [AABB-Triangle · 3DCollisions (gitbooks.io)](https://gdbooks.gitbooks.io/3dcollisions/content/Chapter4/aabb-triangle.html)

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [August 11, 2023, 1:18pm UTC](https://forum.babylonjs.com/t/box-shaped-raycast-equivalent-in-babylonjs/43190/3 "2023-08-11T13:18:34Z")

</div>

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

For eg:

> [@3rd person tank controls: jitter when walking down ramp](https://forum.babylonjs.com/t/3rd-person-tank-controls-jitter-when-walking-down-ramp/33683):
>
> Hello Everyone, I am creating 3rd person tank-style controls with the ability to jump (Roughly cobbled together and modified from various other playgrounds). Here it is (WASD to move, Z to jump. Adjust camera with mouse): Everything works fine, except there is a jitter when walking down ramps. Does anyone know how to fix it so movement is smooth? I used intersectsMesh instead of rays for detecting standing on the floor because I want it to behave more realistically when people step off ledg…
