Physics Manager - Set default Material by Script

Hey,

is there a way to access / set the Physics default Material by script?

Something like:

private var newStandart : PhysicsMaterial = new PhysicMaterial();

function Start () {
   newStandart.dynamicFriction = 0.12345;
   Physics.defaultMaterial = newStandart; // something like "Physics.defaultMaterial" does not exist..
}

bump

I too would like to access the default physics material by script.
According to its tooltip in the project settings, “Default Material” is:

To reflect this behavior in code we should be able to do something simple like this:

return myCollider.sharedMaterial ?? Physics.defaultMaterial;

After some playing around I found some workarounds:

If you create a PhysicMaterial (let’s call it default_pm) and set it as the default material in the physics settings, you can virtually change the default physics material by changing the values of default_pm.

Also, it appears that calling new PhysicMaterial() creates exact copies of the default material in the project settings, allowing you to indirectly read its values.

So even though we can’t swap out the default material object, we can get similar functionality using these tricks.