# Ray hit returns false for some parts of a mesh (playground link)

**URL:** <https://forum.babylonjs.com/t/ray-hit-returns-false-for-some-parts-of-a-mesh-playground-link/54876>\
**Category:** Bugs\
**Created:** [November 19, 2024, 11:01pm UTC](https://forum.babylonjs.com/t/ray-hit-returns-false-for-some-parts-of-a-mesh-playground-link/54876 "2024-11-19T23:01:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![immunity](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/immunity/32/40353_2.png) [@immunity](https://forum.babylonjs.com/u/immunity)\
**Post date:** [November 19, 2024, 11:01pm UTC](https://forum.babylonjs.com/t/ray-hit-returns-false-for-some-parts-of-a-mesh-playground-link/54876/1 "2024-11-19T23:01:38Z")

</div>

Hello, I am trying to find out if an object/user is on top of a platform which is a merge mesh of boxes. Ray intersects with the ground/platform will return hit === false for some parts of the mesh/platform. (This is also happening when I create the platform using ExtrudeShape)

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/3/3/3316d5641ce242abd2966e517c0d1b56bb0538ba.jpeg)

> **[Babylon.js Playground](https://playground.babylonjs.com/#NJ0ARO)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL and WebGPU 3D scenes

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [November 20, 2024, 1:16am UTC](https://forum.babylonjs.com/t/ray-hit-returns-false-for-some-parts-of-a-mesh-playground-link/54876/2 "2024-11-20T01:16:24Z")

</div>

cc @Cedric

---

<div class="post-metadata">

**Author:** ![immunity](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/immunity/32/40353_2.png) [@immunity](https://forum.babylonjs.com/u/immunity)\
**Post date:** [November 20, 2024, 10:57am UTC](https://forum.babylonjs.com/t/ray-hit-returns-false-for-some-parts-of-a-mesh-playground-link/54876/3 "2024-11-20T10:57:31Z")

</div>

I think the “problem” is changing platform’s position (zigzagGround.position.z = -20); the physicBody visually is moved but ray check doesn’t identify it. I added an extra(D) ray on position that hits the platform when platform.position === (0,0,0) I moved again platform.position.z = -20 and ray D visually doesn’t hit the platform but ray.intersects report as it hits

> **[Babylon.js Playground](https://playground.babylonjs.com/#NJ0ARO%233)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL and WebGPU 3D scenes

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [November 20, 2024, 1:03pm UTC](https://forum.babylonjs.com/t/ray-hit-returns-false-for-some-parts-of-a-mesh-playground-link/54876/4 "2024-11-20T13:03:20Z")

</div>

A good test would be to do raycasts with origin points on a X/Z plane and see where it hits by changing raycast color.  
Either there is a bug in physics engine raycast code or an issue in coordinate transformation in Babylon layer.

EDIT: intersects method doesn’t use physics engine.

EDIT2: explanation is in this page : [Babylon.js docs](https://doc.babylonjs.com/features/featuresDeepDive/mesh/interactions/picking_collisions#alternative-picking-methods)  
ray neede to be transformed into mesh local coordinates, or in other words, it needs to be transformed by mesh world matrix inverse.  
Or use the `intersectsMesh` like in this PG: [https://playground.babylonjs.com/#NJ0ARO#5](https://playground.babylonjs.com/#NJ0ARO#5)
