- Home /
Car falls through terrain
Hi Im having a collider problem... for testing i had all the objects in my scene arranged on a cube. Now I wanted to add Terrain, so I deleted the cube and moved everything onto the terrain. Worked fine, except for one thing. My car fell through the terrain. Its colliders are generated during Importing. I read, that I had to use a primitive collider if I had a rigidbody on the object, but it worked well while it was placed on the cube, so why shouldnt it on the terrain? Well, I hope someone can help the newbie I am. Cheers
Answer by Lo0NuhtiK · Jan 21, 2012 at 12:39 AM
Your car probably has a mesh collider. Mesh against mesh, or mesh against terrain 'ghost' through eachother every time I've ever tried it. If your car has wheel colliders, then those should keep you above ground, but then when you flip your car over somehow on a jump or whatever, the top part of it will ghost through while leaving the wheels on the ground above.
If your car has a mesh collider, that's fine. Add some wheel collider's to it if you're planning on making it control the 'right' way with torque etc .
Then make some child empty gameobjects for the car too. Give each one of them a primitive collider of some sort and position/size them at places like the front bumper, rear bumper, roof of the car ;... places like that. Then, when/if your car flips over those primitive colliders will keep it from ghosting through the terrain, but you'll still also have your mesh collider to use for other stuff e.g. you want to shoot your car and put bullet hole decals on it in the right spot rather than floating out away from the mesh on a box collider.
Then, another way, if you don't want to go through doing all that other stuff.
You could simply mark your cars mesh collider as 'convex' in the inspector. This makes the collider something like a primitive and shapes it around your meshes outermost vertices in a way ; and it should keep you on the surface.
Answer by TopsyKretts · Jan 21, 2012 at 04:34 PM
Thank you very much. Now my only Problem is the mesh collider. I imported my Model from a 3ds file. Its made from several meshes and grouped in a prefab. Is there a way to create only one mesh collider from all these meshes? Or do I need to create one for each part I want to collide? Another thing is that when I choose generate colliders and drag it into my scene the object does not have a mesh collider, but it did collide with the cube like i said, so it has to have some sort of collision... Well, I hope Ill figure it out. And thanks for the detailed answer again.
Your answer
Follow this Question
Related Questions
Terrain collider is inaccurate 3 Answers
All colliders no longer work. 0 Answers