Getting physics ignorance layers from script

I’m putting together an extension script to do more robust physics at high speed (hope to make it available if it works - should provide something more robust than Don’tFallThroughThings). I’m trying to make it easy for anyone to use (but also expose more advanced tools for those who need it).

Briefly: it’s based on SphereCasts (just those for now - extending out based on collider type should be fairly easy). Sphere casts have a layer inclusion option.

I wanted to make sure that in its simplest form, it’d use the same layer as the rigidbody it’s being applied to and then establish what layers it should ignore based on the Physics Manager Matrix (so that ignores all layers that it’s been set up to ignore). At the moment I have to declare this manually.

Is there any way to pass a Layer number into Physics, and have a layer mask return which tells you which layers are ignored/noticed?

I believe there’s only one way to do this, which is through the

You basically scan the layer array, and call the layer collision getter with your reference layer as a source. Then you can decide how to manage that, for example by populating a custom array or matrix (there seems to lack a specific such object in the physics panel to access).