has been confused in Unity3d in the trigger and collision message under what conditions can occur, peacetime is also smattering. AX, it is time to send some time to solve this problem once and for all XD.
Ontriggerenter, Ontriggerstay, Ontriggerexit is for triggering class messages, recorded as Trigger
Oncollisionenter, Oncollisionstay, Oncollisionexit is a collision class message, recorded as collision
None means none of the two types of messages have happened.
If the object has a rigid body (rigidbody) and its iskinematic option is checked, it is recorded as KT, otherwise it is recorded as KF
If the object has a collision Body (collider) and its Istrigger option is checked, it is recorded as TT, otherwise it is recorded as TF
(KT,TT) indicates that the object has a rigid component and its iskinematic option is checked, with the collider component and its Istrigger option checked
(KT,TF),(KF,TT),(KF,TF) and so on
|
Kf |
Kt |
Kf |
None |
None |
Kt |
None |
None |
Can see no message generated
|
Tf |
Tt |
Tf |
None |
None |
Tt |
None |
None |
Can see and no news generated
|
(TF, KF) |
(TF,KT) |
(TT,KF) |
(TT,KT) |
Tf |
Collision |
None |
Trigger |
Trigger |
Tt |
Trigger |
Trigger |
Trigger |
Trigger |
Kf |
None |
None |
None |
None |
Kt |
None |
None |
None |
None |
You can see that two objects are required to generate a message with a collision body component and at least one object has a rigid component
|
(TF, KF) |
(TF,KT) |
(TT,KF) |
(TT,KT) |
(TF, KF) |
Collision |
Collision |
Trigger |
Trigger |
(TF,KT) |
Collision |
None |
Trigger |
Trigger |
(TT,KF) |
Trigger |
Trigger |
Trigger |
Trigger |
(TT,KT) |
Trigger |
Trigger |
Trigger |
Trigger |
Can see
To generate a trigger message: at least one of the Istigger options for the collider component is checked
To generate a collision message: The Istrigger option for two collider components is unchecked and the iskinematic option for at least one rigid body component is not selected
Conclusion:
Basic conditions for generating a message: Two objects have a collider component and at least one object has a rigid body component
To produce a trigger class message: In addition to satisfying the basic conditions, there is at least one Istigger option for the collider component checked
To produce a collision class message: Except for the basic conditions, the Istrigger option for the two collider components is unchecked and the iskinematic option for at least one rigid body component is not selected
Trigger and collision messages in Unity3d and rigid and colliding bodies