[SOLVED] How to use Raycast?

Yes, raycastFirst will return the first rigidbody found.

If you would like to filter the context at which you are doing the raycast, look for physics groups. Those aren’t exposed in Playcanvas but Ammo supports them and potentially can be handy.

Otherwise instead of physics you could use the pc.BoundingBox class, which has its own raycast method. And you can control the list of entities you are raycasting to. Here is an example:

https://developer.playcanvas.com/en/tutorials/entity-picking-without-physics/