0
\$\begingroup\$

I use Unity and the player controller in the game is acting strangely. It has a Character Controller but no Rigidbody. I use CharacterController.Move to make him run and walk. I disable his collider, but it has a script in which there is an OnTriggerEnter function. I notice that the character is having collisions with objects that have colliders marked "Is Trigger" but no Rigidbody.

How is this possible?

\$\endgroup\$

1 Answer 1

3
\$\begingroup\$

As shown in the scripting API docs, CharacterController inherits from Collider, so the controller component itself can generate physics trigger messages - even if no other (enabled) collider is attached to it or present in one of its child objects. Its capsule center/radius/height define the shape and size of its trigger volume.

This capsule shape behaves like a "Kinematic Trigger Collider" according to the "Interaction between collider types" documented here, even if it has no attached Rigidbody. The controller wraps functionality similar to what we get from a kinematic Rigidbody, adapted to common character control use cases.

I'd like to see this stated more explicitly in the Unity documentation, but you can see it does mention that these components can generate trigger messages:

Note that changing Character Controller properties in the inspector will recreate the controller in the scene, so any existing Trigger contacts will get lost, and you will not get any OnTriggerEntered messages until the controller is moved again.

\$\endgroup\$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.