How to give an object gravity without it falling through the terrain

Hello,

I’m making an FPS game in Unity3D. I’m using a First-Person controller on a grass world, but whenever I give any object gravity, it just falls through the terrain. Any help would be great!

Thanks.

Here is a package with a working scene showing rigidbodys colliding and reacting with a terrain. It uses the RigidbodyFPSWalker script on the Unity Wiki, which I modified to actually rotate and then shoot ‘cannonballs’ . Now the controller doesn’t use gravity, but look at the projectile prefab. It is just a primitive sphere with a sphere collider and a rigidbody that is using gravity.

Edit : create a new project, import the package, open the scene and hit play. Use wasd to move, space to jump, Left-Mouse-Button to shoot.

attach a rigid body to the ground and then tell the rigid body you just attached to not use gravity. It should be a check box you can uncheck in the inspector for the ground.

-Edit-
As long as you have a rigid body attached to your character, then you’ll be golden. You can also mess with the mass value of the ground too if you feel like your character isn’t moving very quickly.

-Edit 2-
Sorry for all the edits, I keep remembering things as I go through the process in my head. You’ll probably also want to constrain the x, y, and z rotation and position variables for the ground too under the rigid body. If another rigid body hits it, it’ll end up knocking it away unless you constrain those 6 variables. Ok, I think that’s the last thing…

Hmmm, I attached the RigidBody to the First-Person Controller and the terrain, but now it glitches and I rocket up to space. I tried locking the X, Y and Z of the player and the terrain, but that only put me back in the first place: I fall through the terrain.

Thanks for your effort everyone! But I think I will just use objects without gravity.