I have put a rigidbody and a character controller on my character. I have placed a cube under it, and it falls through the cube. It will also fall through the terrain.
I am only able to make it stay on the ground if I add a third person controller, but then that controller messes up my other scripts. When it did have a third person controller, it would also walk through trees even though on the terrain it would have tree colliders.
Is there something I’m doing wrong?
Try making the rigidbody kinematic (if you absolutely need it) or remove it. Rigidbodies and Character Controllers don’t work that well together.
I was having the same problem.
Rigidbodies and Character Controllers don’t work that well together.
I just deleted the rigidbody component from my character and it works well.
But why? I want my character follows the physics given by rigidbody!
This answers the question:
Fix: Just create a new project, add a plane (reset it so it is located at 0,0,0), then add a capsule gameobject. To the capsule, add the rigidbody component and then the character controller. Check that the capsule, the rigidbody and the character controller are, in fact, zeroed (reset them so they are located at 0,0,0). Push up the combined object so it is above the plane by 0.1-0.25. When you play the scene, the combined object will fall to the ground. Last resort fix is to use the constraint option in the rigidbody: set Freeze Position in the Y axe to true.
Explanation: Intersecting colliders (the one from the movable object and the one from the plane) create a “hole” in the plane in which the controlled object falls at runtime. Bear in mind that some scenery is created with software like Maya and such and the artist did not use the origin point (0,0,0) to create his/her scenery. Sometimes, they didn’t even created the required colliders and hence, a rigidbody will fall because there is no real “ground”. One last possibility is that you have too many objects with big meshes. In this case, Unity will try to keep in memory all your stuff but it will fail to do so and weird things will happen, such as things that were working will not,animations won’t animate and rigidbodies will fall through the ground. This is the reason why you should keep your polycount low.