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.

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.

2 Replies

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.

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.