Search Unity

Undocumented things about physic materials

Discussion in 'Scripting' started by Vadelma, Oct 13, 2010.

  1. Vadelma

    Vadelma

    Joined:
    Sep 25, 2010
    Posts:
    2
    By testing Unity 3 (free license), I've learned two important things about physic materials that are undocumented. I thought it would be nice to share this information here so that other people don't have to find out these things themselves. This information might not be 100% correct - feel free to correct me if I'm wrong.

    1. Realtime changes to the properties of a PhysicMaterial object won't (immediately) affect the collisions between colliders whose bounding boxes (aligned with X, Y and Z axis) are touching during the change. These collisions will only be affected by the change after the two bounding boxes have been separated (for at least one physics update?). I believe this happens because the physics engine temporarily memorizes information on friction and bounciness between colliders for faster performance.

    Fortunately, if you change the whole PhysicMaterial object from either collider, the change always affects all the collisions it should, immediately. If you can't have a predetermined set of physic materials, you could create a new PhysicMaterial instanses every time a change to a physic material is needed. However, to avoid constantly creating new objects and lowering performance, you might want to constantly switch between two PhysicMaterial objects (representing the same physic material) every time you want to make change into the properties of the physic material (you have to make the changes to both of the objects, or apply the combination of the two latest changes at once into the object you are now switching to).


    2. In collisions between two colliders, if the physic materials have different bounceCombine or frictionCombine, the PhysicMaterialCombine with the highest priority is applied. The lower the suggested PhysicMaterialCombine is in the list of choises in the inspector window, the higher its priority is. So the PhysicMaterialCombines from the lowest priority to the highest priority are: Average, Multiply, Minimum, Maximum.
     
    krille71 likes this.