Trigger and collision messages in Unity3d and rigid and colliding bodies

Source: Internet
Author: User

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


    • In case one, two objects have only a rigid body component:


Kf Kt
Kf None None
Kt None None

Can see no message generated


    • Scenario two, two objects are only collision body components:


Tf Tt
Tf None None
Tt None None

Can see and no news generated


    • Scenario three, one object has a rigid component and a collision body component, while the other object is only a collision body component or only a rigid body component


(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


    • Case four, two objects have a rigid component and a collision body assembly


(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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.