I have a player that consists on a root object with the Character Controller attached and some children with its components. Those have box colliders attached.

When moving the player I want to be able to collide with other objects using the box colliders, but it won't, instead it will only collide with the Character Controller.


As you can see in the image, the red object didn't stop when the collider crashed with the framed cube, but it did when it did with the Character Controller.

There is any way to use the player colliders instead of the Character Controller for collision detection?

  • \$\begingroup\$ Could you provide a video / some pictures / illustrations of your issue please? \$\endgroup\$ – Natalo77 Apr 15 '20 at 13:04
  • \$\begingroup\$ Sure, added image and a bit of explanation. \$\endgroup\$ – Hector Apr 15 '20 at 14:45
  • \$\begingroup\$ Looks like maybe it's the sphere collider on the red that is colliding - Is your box collider set up to respond correctly? \$\endgroup\$ – Natalo77 Apr 15 '20 at 16:46
  • \$\begingroup\$ Yes, that sphere collider is the character controller. What do you mean exactly when you ask if my box collider is set up to respond correctly? \$\endgroup\$ – Hector Apr 15 '20 at 16:58
  • \$\begingroup\$ usually physics engines have certain channels or Object Types for collision (Pawn, Vehicle, Prop etc.) From the behaviour your problem displays, it makes it seem like the Object type or channel your colliders are set up with are not set to respond to eachother's channel/Type \$\endgroup\$ – Natalo77 Apr 16 '20 at 8:30

I solved it by using a non kinematic rigidbody on the root player object instead of a Character Controller. I've also changed the cube rigidbody to a kinematic one, since that shouldn't move.

Now I'm using RigidBody.velocity to move the player instead of characterController.Move. Perhaps I should use AddForce instead.

Also, in order to prevent unwanted movements I've put constraints on the x,y,z rigidbody rotantion and y translation (I only want to move the character in 2D). I don't know if this is necessary or could be done different.

Now the collision is done properly, but, as I said, some things I'm not sure if they could be done better.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.