- Home /
Character falls through floor even with character controller and rigidbody attached
Hi,
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?
Answer by Cyberpie_n_milk · Mar 19, 2013 at 05:38 PM
Try making the rigidbody kinematic (if you absolutely need it) or remove it. Rigidbodies and Character Controllers don't work that well together.
I made it kinematic. Now it won't fall even after i delete it.
Oh, so you were using a rigidbody for gravity? If so, that won't work. Ins$$anonymous$$d you have to add gravity through script, like this example.
It works, but it will still fall through the floor...
Are you sure the layers are set to collide with each other?
Yeah I created a player layer and assigned it to my character
Answer by tingfungc · Jul 08, 2013 at 01:21 PM
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!
Answer by cmonroy · May 09, 2014 at 09:18 AM
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.
Thank you for this! $$anonymous$$uch appreciated. This was an old problem, and I think I fixed it, but I will definitely take your advice. I believe my character was too high-poly, or the character controller and rigidbody weren't working well together.
All in all, I am grateful for your response.