Possible causes for oncollision and Ontrigger not responding

Source: Internet
Author: User

When detecting collisions with the Unity API, you often encounter situations where oncollision and Ontrigger are not responding, so summarize the possible causes.
void Oncollisionenter (collision other)
-Requires both Collider and Rigidbody.
-If the parties have rigidbody, then the iskinematic should not be checked .

void Ontriggerenter (Collider other):
-Need to have at least one rigidbody on both sides
-Can be checked iskinematic
-Both parties must tick the Istrigger on the collider component

The problem I encountered in development was that all two had collider, but one of them had a rigidbody, and previously checked iskinematic, which led to Oncollisionenter's inability to respond. Because the one with the rigidbody I don't want it to be affected by the rigid body physics engine, so take another strategy: Set gravity scale to 0,iskinematic unchecked.

In addition to the use of the differences, the functions of the two are also different, from the two parameters can be seen. Collision get more information than collider, in addition to collider contains information, collision can also get the coordinates of the points they contact.

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.