- Home /
The question is answered
How to keep rigidbody from falling through terrain?
I instantiate a prefab object into the world, and after like 10 times the objects keeps falling through the ground. Both the ground and the object have rigidbodies on them to make sure that they see eachother. For some reason the object that I am creating stops colliding with the terrain after a certain number of times. The only thing working on the falling object is gravity via rigidbody component. I do have a character with character controller and third person controller in the scene as I am performing instatiation. Any help will do.
can we see some pictures or any code that you wrote so we can assist easier?
How thick (in terms of it's height, y axis) is the ground. If it is very thin then objects can easily push through it enough to fall through completely.
The speed of the object seems to be fairly slow, it seems to be affected only by gravity that rigidbody component applies to it. However, when it starts to shoot out in random directions, a more stronger force seems to be apply to it.
The ground is generated via the unity terrain creator, so I guess that would make the ground paper thin.
Answer by The-Little-Guy · Nov 19, 2014 at 11:59 PM
Create the ground without a rigidbody, and place a collider on it instead. Your ground probably doesn't need to react to physics, but your object will need to react to physics so it will need a riggidbody on it AND a collider as well. You then place a Physics Material on the ground collider (which is optional) to apply either friction and/or bounciness to your player or game object.
I am using an imported mesh for my terrain. There's no rigid body or Physics material on it, just a mesh collider generated by script when it is instantiated and shaped using perlin noise. I still sometimes have issues when I instantiate objects above it. They fall through it, not all of the time, but sometimes. The smaller the object the higher the chance of it falling through.
It's okay, I solved my problem by changing the rigid body settings on the Objects to Extrapolate and Continuous Dynamic. Having a rigid body on my terrain is also essential for using an object placement system I am using.
Answer by sticoRobotto · Nov 20, 2014 at 01:01 AM
Cool thanks. I have removed the rigidbody from the terrain. I think part of the problem was that I was placing a rigidbody along with the Character controller, and there were two forces at work. I have removed the rigidbody from the Player gameobject. It seems to be working fine now.
No problem! Note: You shouldn't post comments to answers as a new answer, you should post it in the comments of the answer.
Follow this Question
Related Questions
My object falls through terrain. 8 Answers
Force on Character Controller (Knockback) 4 Answers
Object Flies into Air Upon Collision, or goes through hill depending on isKinematic settings 1 Answer
How to setup character Collisions? 2 Answers
CharacterController jumps when colliding with kinematic rigidbodies 1 Answer