OnTriggerEnter insanity

I’ve run into a really weird problem with the OnTriggerEnter functionality.

I have a simple cube with a trigger collider. It has a simple script that prints the name of each collider that triggers the cube.

I also have two objects to test triggering with. One is a simple capsule collider (a trigger too, for other reasons) that is parented to the ‘player’ object.
This capsule collider has a rigidbody because even though it doesn’t move at all by itself, it needs one to make its own trigger work properly (weird thing of Unity, but not a problem. Never really found an answer to that, too so if you know why, please do enlighten me)

The other object to test triggering with is a Character Controller, which means a capsule collider. And that’s when things start getting weird:

At first, everything worked perfectly fine. The cube-trigger was triggered properly by the character controller. I didn’t adjust any relevant settings of the colliders or anything in scripts that check the collision. But after some time and scripting in completely seperate scripts it suddenly stopped working.

Right now, when I jump my Character Controller into the cube-trigger. Nothing happens.
I have the functionality that puts the scale.y to 0.5 so the player can crouch. When I do this, though, it triggers! But the only difference is the scale of the object!

It’s driving me insane. The Character Controller is identical to the other capsule collider (which is working), but the Controller doesn’t work except when its scale has changed!

I doubt anyone has any idea to how to fix this. I hope it’s not some weird Unity engine glitch.

I wouldn’t say it’s a glitch :wink: The main problem is that “normal” collision / trigger detection is done by the physics system. That’s why you need a rigidbody to get that functionality. Colliders by itself can’t do anything. If you move two objects with colliders (no matter if trigger or not) into each other, nothing will happen. You won’t get any messages nor will the collider stop (if both are colliders).

When one or both objects have a rigidbody, you will get OnTriggerEnter / OnCollisionEnter.

The CharacterController is a very special case. From the physics system’s point of view it’s just a static collider (even it does move ;)). The CharacterController has it’s own collision detection system when you use Move or SimpleMove. This collision detection system don’t trigger any of the above mentioned events. It has it’s own event: OnControllerColliderHit. It doesn’t detect triggers since it only cares about it’s own movement.

Trigger messages are still possible with the CharacterController when the other collider has a rigidbody attached, but if the other RB falls asleep, it can’t detect collisions anymore.

The best way is to use a seperate collider to detect trigger events and attach a rigidbody to this object.