RayCast is hitting a trigger volume


Hello, in my game I have a trigger volume entity that surrounds the player, but it appears that it is being hit by raycasts.
The API states that only entities with rigidbodies will be hit by a raycast, is this no longer true? Or is there a way to stop trigger volumes from interfering with raycasts?

Looking at the scene, your ‘Player’ entity has a Rigidbody so raycasts will ‘hit’ it.

I had a temporary fix that disabled the collision on the trigger volume surrounding the player (in the scene it is a sub entity of player called ‘PickupCollector’. I have now disabled that fix, so now when I do a raycast from the camera to see what the player is looking at, it hits the trigger volume.

Also all the enemies in the scene are, by the API’s definition, Trigger Volumes, yet they too get hit by raycasts.
If you disable the collision on ‘PickupCollector’ (so that you can shoot normally), you can still hit the enemies, despite them only being Trigger Volumes.
Here is the code for the hit detection, which uses raycasting to detect a hit:

Looking at the raycast tutorial, looks like it is a ‘deliberate’ feature and that the API documentation is incorrect.

For the moment, I recommend adding filters to help get around this issue: Raycast through multiple entities

Edit: On a closer look, it looks like a trigger in PlayCanvas is just a rigidbody in Ammo but with no collision response: https://github.com/playcanvas/engine/blob/18bdc36d108031beca3fbfab948feb911eea2159/src/framework/components/collision/trigger.js#L54