Version: 2022.2

Collider.layerOverridePriority

切换到手册
public int layerOverridePriority ;

描述

A decision priority assigned to this Collider used when there is a conflicting decision on whether a Collider can contact another Collider.

The Layer Collision Matrix defines which layers can contact other layers. Additionally, you can include and exclude layers per Collider or for all Colliders attached to a specific Rigidbody or ArticulationBody. Any contact involves two different Collider instances. Unfortunately this can result in one Collider deciding that it should contact the other Collider, but the other Collider deciding it shouldn't. There are rules to decide how these situations are handled.

The rules for making a decision between two Colliders, referred to here as A and B, are made in the following order: If both A and B make the same decision then use that decision. If only A or B are using a layer include or exclude override, then use the decision for A or B that has the include or exclude override specified. If both A and B are using a layer include or exclude override, then use the decision from A or B that has the higher Collider.layerOverridePriority. If A and B have the same Collider.layerOverridePriority, then the decision will be to not create a contact. See Also: Collider.includeLayers, Collider.excludeLayers, Rigidbody.includeLayers, Rigidbody.excludeLayers, ArticulationBody.includeLayers, ArticulationBody.excludeLayers.