0
votes

I have a Terrain and Cube. Terrain has terrain collider attached and cube has box collider on it. But still cube is falling through the terrain. I tried lot of things explained in other questions and on other forums but none of them has fixed the issue. Screenshot of both cube and terrain setting is attached below.

Cube Settings: Cube Settings

Terrain Settings: Terrain Settings

2
if you want Unity's collision system to work correctly you need to handle all of your movement through their physic system, by moving the position directly you are bypassing unitys physics updates. - AresCaelum
so issue is with the move script... - MAY
np, i bet if you deactivated your scripts, and made the cube use gravity(By adding a rigidbody) it would land on the terrain =) - AresCaelum
There are 2 reasons for your issue, 1 in order for collisions to happen in unity one of your objects need a rigidbody. 2. Moving an object by its transform directly in update will bypass the Fixed loop Unity uses for collisions. So for example you move your object every frame based off of time.deltaTime, when the physics loop happens it will attempt to do a seperation of the 2 objects. that seperation can only be seperated so much in the physics loops to keep things looking natural, if you had a slower move rate, and a rigibody on your cube you would probably see it jitter as it passed. - AresCaelum

2 Answers

5
votes

you need to add a rigid body to the cude AND make sure that this rigid body has the property of "is Trigger" not enabled, if u needed enabled u need to wrap the whole cube inside empty object and make it enabled in the new wrapper and disabled in the cube, this will solve the probelm

1
votes

It's because your cube need a rigidBody component.

After manage the gravity with this component and if you have to move your cube do it in the FixedUpdate, not the Update.