- Home /
CharacterController with BoxCollider
Hello! So I'm using CharacterController for sprite movement and collision. I also attached child BoxColliders (set as Triggers) to detect collisions with various environmental triggers. I quickly realized that the BoxColliders were not registering collisions with anything in the scene. After banging my head for a bit I came to the conclusion that this was because their parent (CharacterController) is not under control of the regular physics engine; it seems like the equivalent of manipulating the BoxCollider's transform manually.
I'm wondering if there is a workaround for this or am I simply doing something wrong?? Any suggestions would be very much appreciated. Thanks!
EDIT: For clarification. I have a CharacterController gameobject. It has a child attached with a BoxCollider (IsTrigger set) and a simple script that prints when OnTriggerEnter. I move the CharacterController with Move. I also have a few separate gameobjects in the scene, each of which have a BoxCollider attached with IsTrigger set. The OnTrigger* events are not firing on the child of the controller when it passes through my scene triggers.
Could you provide a snippet of the script that isn't working?
From what I understand, you set Box Colliders on an Object with a Character Controller (which actually acts as the Collider for your Character).
To detect collisions of the character controller you need to use the OnControllerColliderHit(hit : ControllerColliderHit).
Answer by whydoidoit · Aug 21, 2013 at 09:15 AM
Something involved in a collision requires a rigidbody on it; it can be set to isKinematic = true so that it won't affect the standard processing of a CharacterController. The thing with the rigidbody gets the message - so you will get it on the child if the child has the rigidbody, otherwise on the parent.
Aww yes! Thank you, that did it. I felt like I was missing something there!
This doesn't seem to be required in the current version (Unity 5). CharacterControllers do seem to register collisions with triggers now.