How do I not let a dynamic rigidbody respond to a (specific) collider on another entity?
Oof. This is not well supported by PlayCanvas unfortunately. Physics has a layer system where you can set if something in one layer collides with another layer. It requires using the physics SDK API though.
Here is an example but you also have to look through Bullet documentation to understand how the layers and masking works
I think i understand the idea in the sample project, but i don’t know what is a SDK API.
The physics in PlayCanvas uses a library called Ammo.js which is JS compiled version of the Bullet physics library. The PlayCanvas API only exposes small bit of the functionality but it doesn’t stop us from using the features in the Ammo.js library directly.
I don’t see the Ammo.js script in the example project.
Ah, it was done before the engine change to WASM so it was using legacy Ammo.js integration. I have now updated it so it imports the script into the project.
The Ammo.js is compiled C++ into JS though so you won’t be able to humanly read it.
Oke so if i understand it well, first i have to add the scripts in the Ammo folder to my project.
Then i can add the Physics-Layer script on the entities and
determine which entities has to react on eachother?
You don’t have to. Just by enabling Physics in the project settings already integrates Ammo.js into the project, you can just can’t see it in the project and it doesn’t use the optimised WASM version.
Yep, you can just copy it in.
Oke, i will try. Thanks!
Can you explain when i have to use the trigger-layer script instead of the physics-layer script?
Want collisions? physics-layer
Want triggers? trigger-layer
It seems to work.
Is it true that a rigidbody with this script ignores a collider without this script?
If so, is there a way to not ignore a collider without the script? Otherwise it is very difficult to keep track of everything.
I believe so.
You can patch the engine to assign all the layers to a rigid body by default.
The default raycasfFirst from the engine doesn’t support layers but it is possible to create your own that uses a mask only return objects on certain layers.
Right now, triggers are basically physics shapes in the simulation that don’t move and are on a physics layer that rigid bodies can pass through.