# HavokPlugin.raycast does not use collideWith filterMask correctly when raycasting against trigger shapes

**URL:** <https://forum.babylonjs.com/t/havokplugin-raycast-does-not-use-collidewith-filtermask-correctly-when-raycasting-against-trigger-shapes/53086>\
**Category:** Bugs\
**Tags:** physics, havok\
**Created:** [August 29, 2024, 8:13am UTC](https://forum.babylonjs.com/t/havokplugin-raycast-does-not-use-collidewith-filtermask-correctly-when-raycasting-against-trigger-shapes/53086 "2024-08-29T08:13:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![erikhoj](https://avatars.discourse-cdn.com/v4/letter/e/ea5d25/32.png) [@erikhoj](https://forum.babylonjs.com/u/erikhoj)\
**Post date:** [August 29, 2024, 8:13am UTC](https://forum.babylonjs.com/t/havokplugin-raycast-does-not-use-collidewith-filtermask-correctly-when-raycasting-against-trigger-shapes/53086/1 "2024-08-29T08:13:48Z")

</div>

Hello!

I ran into an issue when trying to raycast against triggers. The raycast works fine as long as I don’t use the collideWith filter. However, as soon as I define that, the raycast no longer collides with the triggers, even if all the filters line up.

The bug can be seen here: [https://playground.babylonjs.com/#BF7GJA#2](https://playground.babylonjs.com/#BF7GJA#2)

---

<div class="post-metadata">

**Author:** ![erikhoj](https://avatars.discourse-cdn.com/v4/letter/e/ea5d25/32.png) [@erikhoj](https://forum.babylonjs.com/u/erikhoj)\
**Post date:** [August 29, 2024, 8:25am UTC](https://forum.babylonjs.com/t/havokplugin-raycast-does-not-use-collidewith-filtermask-correctly-when-raycasting-against-trigger-shapes/53086/2 "2024-08-29T08:25:05Z")

</div>

Looking through the source code here:

> <https://github.com/BabylonJS/Babylon.js/blob/master/packages/dev/core/src/Physics/v2/Plugins/havokPlugin.ts#L2108>

It seems like shouldHitTriggers is always set to false. It’s very odd that a raycast without a collideWith mask hits a trigger then. I just tested locally by reimplementing the functionality and raycasting with shouldHitTriggers=true, and it works like expected.

Is it possible that you could include a configuration option in the raycast query so we can make raycasts that hit triggers aswell. It seems a little odd to leave it out, especially when it is not mentioned in the documentation.

---

<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:** [August 29, 2024, 9:21am UTC](https://forum.babylonjs.com/t/havokplugin-raycast-does-not-use-collidewith-filtermask-correctly-when-raycasting-against-trigger-shapes/53086/3 "2024-08-29T09:21:20Z")

</div>



---

<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:** [August 29, 2024, 9:28am UTC](https://forum.babylonjs.com/t/havokplugin-raycast-does-not-use-collidewith-filtermask-correctly-when-raycasting-against-trigger-shapes/53086/4 "2024-08-29T09:28:36Z")

</div>

Let me add that to the query options!

---

<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:** [August 29, 2024, 9:45am UTC](https://forum.babylonjs.com/t/havokplugin-raycast-does-not-use-collidewith-filtermask-correctly-when-raycasting-against-trigger-shapes/53086/5 "2024-08-29T09:45:21Z")

</div>

> <https://github.com/BabylonJS/Babylon.js/pull/15494>

---

<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:** [August 29, 2024, 9:45am UTC](https://forum.babylonjs.com/t/havokplugin-raycast-does-not-use-collidewith-filtermask-correctly-when-raycasting-against-trigger-shapes/53086/6 "2024-08-29T09:45:25Z")

</div>



---

<div class="post-metadata">

**Author:** ![erikhoj](https://avatars.discourse-cdn.com/v4/letter/e/ea5d25/32.png) [@erikhoj](https://forum.babylonjs.com/u/erikhoj)\
**Post date:** [August 30, 2024, 7:45am UTC](https://forum.babylonjs.com/t/havokplugin-raycast-does-not-use-collidewith-filtermask-correctly-when-raycasting-against-trigger-shapes/53086/7 "2024-08-30T07:45:11Z")

</div>

Thanks Cedric! 🙂
