Raycast to Ignore a Collision Trigger. How?

I am performing raycasts for my player navigation (click the floor to move). Within my scene there are various trigger boxes which when walked into perform various functions.

I want the movement system to ignore the trigger boxes and just detect for the floor collider. In Unity there is an ‘Ignore Raycast’ feature on colliders but there doesnt seem to be any way to do this in Playcanvas.

Any idea on how to achieve this in the most simplest way possible?

You can do something like this with raycastAll and tags. eg Physics raycasting by tag | Learn PlayCanvas

Note that raycastAll doesn’t sort results by distance.

The engine release of 1.62 (in RC) adds new raycast functions to make this easier: Implements results filtering for `raycastAll` and `raycastFirst` by MushAsterion · Pull Request #5180 · playcanvas/engine · GitHub

Thanks. How do I get my hands on the new engine release.

In the example I can see how I can filter by one tag (‘green’) but I still don’t see how I can use it to effectively ignore a certain tag. (Unless I maybe disable the object and then maybe fire the ray again.?!?)

What if I want the raycast to be able to detect multiple tags: floor, pickup, interactive object etc but ignore other ones (triggers etc)?


The only way I can seem to do it is to give a ‘clickable’ tag to all my entities that I want to be clicked and I just don’t add the tag to the rest.

It seems a backward way to do things though as I have many objects I’ll need to go through and assign clickable while there are just a couple of objects that wont need the tag.

Currently it is in preview. See newsletter: PlayCanvas Engine v1.62 RC - Updates to Shader Chunks and WebGPU and forum post https://forum.playcanvas.com/t/engine-release-v1-62

  • Tag all the entities you want to ignore.
  • RaycastAll to get all the results that intersect with the raycast.
  • (Potentially optional) Sort results by intersection point distance from the camera.
  • Loop through the results and use the first result that doesn’t have the tag.
1 Like