About On TriggerEnter2D (Collider2D Collision) can not be used

1: The most common is not to add a collision body. Remember to add a 2D collision body. Check the Is Trigger for the detected object or the detected object. It is recommended to use circle collider2D

2: Use this method to at least detect one party plus a rigid body component (Rigidbody). In a few cases, adding a rigid body component is still useless. At this time, you need to change the sleepingmodeMode to never sleep, which is generally not used. Also, check simulate and set the rest to 0 except mass.

3: Check whether the code written is collider2D, and whether the name or label is detected correctly

4: In special cases, if the modified method is used on different surfaces, it is necessary to consider whether the two colliders are at the same level. For example, if two plane objects are placed on different sides of a cube, they cannot be detected when they move to the same surface, because the colliders The surface is still at the original level and will not change as the object changes the surface. The solution is to build two objects on the same surface and then move the other to the specified different surface.

Guess you like

Origin blog.csdn.net/m0_52608003/article/details/130004549