Issues with a characterController, containing a rigidbody


i am having trouble trying to make my character move and react to collisions.

I created an “empty”, set a characterController on it.
Inside this empty i added a rigidbody to the character, and a box collider otherwise the character went through the plane below it.

Now, onCollisionEnter is called directly when i start the scene, how should i just combine a characterController with a rigidbody and a collider?

Also, when i set the dimensions of the charactercontroller “box”, it looks ok, then i set the dimensions of the box collider, but when i start the game, the two of them change their position (like a bit on the right for the first, and a bit to the front for the second one…) Would you know why?

If i set the player to “isKinematic”, and the enemy (a cube with a rigidbody (no-kinematic) inside an empty using a charactercontroller), the print in OnCollisionEnter does not show up.

When i set the position in Edit mode :


When i click on start, and reach the cube : the boxes are not located as before in edit mode, and when i touch the cube, nothing appears in the console :


function OnCollisionEnter(collision : Collision) {

Thanks for your help

The problem you are having is that the CharacterController script is not driven by the physics engine, and a rigidbody is. Simply combining a rigidbody and a CharacterController is subject to all kinds of annoying problems. What you want to be using is the Rigidbody FPSWalker script on the wiki instead as it is designed for manipulating a physics object. Now to answer your other questions… I believe you saw a shift in position because of the “skin width” setting on the character controller, whatever this value is set to causes the character controller to move very slightly out of where you put (this is not its purpose and it is best to leave it at its default) the shift could have also been caused by the rigidbody moving independently of the character controller. the reason OnCollisionEnter was not being called between your two rigidbodies was because I believe a kinematic rigidbody and a normal rigidbody do not both call that function, I think only the normal rigidbody does, but I may be wrong on that.