I’m developing an air hockey game and I want my ball to stay within the borders while the Players could bypass border colliders. Is it possible to remove the border ONLY for the player and ONLY when the player collides the border?
Any concrete code would help me a lot.
Costraint: I need everything not to be kinematic.
What I think you’re asking would be something that the Layer Collision Matrix would help with. You can set a layer for each object you have in scene,
then in EDIT> PROJECT SETTINGS> PHYSICS:
You will see the Layer Collision Matrix. You can set what layer can and cannot collide with one another. You can also add new layers. This is the easier way, otherwise you would need to enable and disable colliders via script depending on your needs. You can also change layers via script… BTW to remove a rigidbody component:
GetComponent<Rigidbody>().enabled = false;