OnTiggerEnter and OnTriggerEnter2D not working properly...

Your title is blaming both 2D and 3D physics trigger callbacks saying they are “not working properly”. Let’s step back and maybe assume it’s what you’re doing. Also, I don’t see anything related to 3D above so that’s doubly confusing.

It seems you’re not aware that only Dynamic bodies contact every other body-type. Static/Kinematic therefore also contact Dynamic but not other Static/Kinematic body-types. To get a Kinematic body-type to produce contacts when contacting other Kinematic/Static body-types, you need to explicitly select that you want that via: Rigidbody2D.useFullKinematicContacts (you can see this in the inspector too).

When I say contacts, I do NOT mean you’ll get a collision response because Kinematics never have that. Instead, contacts will be produced and they will also cause callbacks i.e. OnTrigger/OnCollision.

Note: It’s completely pointless using Continuous with triggers. The body cannot stop at the point of collision because with a trigger there isn’t a point of collision, triggers don’t produce a collision response. Just turn that off as it’s a waste. Also, using the Transform won’t stop physics detecting contacts, it’s just that it’s not how a Rigidbody2D is supposed to move. You are always suppose to use the Rigidbody2D API to cause movement. If you don’t do that, you’re doing it wrong. It’s the Rigidbody2D that is supposed to write to the Transform, not you.

Also, please post code using code-tags rather than pictures of code.

More appropriate forums for you:
2D: Unity Engine - Unity Discussions
Physics: Unity Engine - Unity Discussions

1 Like