Unity Collision Message (ONCOLLISIONXXXX) and trigger message (ONTRIGGERXXXX) Call context

Source: Internet
Author: User

There are a lot of messages in Monobehaviour, a total of 62!

In addition to a series of functions that must be followed in the life cycle of the script, there are two other sets of more frequently confusing messages: collisions and triggering.

According to 3D and 2D objects, and divided into collision: collision, collision2d. Trigger: Trigger, trigger2d.

Taking the three-dimensional object as an example, the following experiments were done to test the ONCOLIISIONXXXX collision message and the ONTRIGGERXXXX trigger message.

Experimental simulations:

1. Create object A and object B, respectively, so that object A is above object B

2. When object A has a rigid body assembly, a force motion is added to object A (rigidbody. Addforce), when object A does not have a rigid body assembly, the displacement Motion (transform) is added to object A. Translate).

3. The gravity-affected option of the rigid body is removed in case the object has a rigid body assembly.

4. Print collision and trigger messages for object A and object B in different combination scenarios, and observe the object crossing situation

The experimental results are as follows:

Study room time to, first come here, go home to fill the conclusion!

Unity Collision Message (ONCOLLISIONXXXX) and trigger message (ONTRIGGERXXXX) Call context

Related Article

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.