- Home /
Vehicle either falls apart or falls through ground.
I have a car resting still on a flat terrain with a collider on both. When I check the convex settings the car does not fall, but splits up into the chassis, wheels and body (repelling each other). When I do not check convex, the car stays in one piece but falls through the ground. Help?
Are the wheels resting well above the ground? Do you have a rigid body on the object? Colliders? Do the fallen apart pieces fall through the ground? This is a pretty vague question.
Answer by schaddemm · Jan 30, 2013 at 12:53 AM
Testing concave meshcolliders vs meshcollider is not supported. (and would probably not be a good idea performance wise). "Mesh Colliders that are marked as Convex can collide with other Mesh Colliders" I don't know if you can test mesh collider vs terrain, but either way I'd think you're probably better off simplifying the collisionmesh of your car into a few boxes.
If youve got something like a bowl its a concave mesh. a ball would be a convex one. concave meshes are way more difficult to compute than convex ones. When you force a mesh to be convex unity fills the gaps, so the bowl will spill its contents. 
So in summary: You probably can't test a concave collider against a terrain collider (and shouldn't). What I think you should be doing is to use a compound collider.
read about this and the other stuff here: http://docs.unity3d.com/Documentation/Manual/Physics.html
Schaddemm: "You shouldn't test convex mesh colliders against terrain". Terrain uses a form of mesh colliders, so a convex mesh will collide with the terrain, but it's not as performant as using primitive child colliders.
You certainly "can" test convex mesh colliders against terrain. I've even done it, but it's not ideal, and rarely have I found that child colliders are not only more performant, but a better design for many shapes.
@Little Angel: Concave you can't test against a terrain collider, convex you (probably) shouldn't.
From the physics manual:
$$anonymous$$esh Colliders cannot collide with each other unless they are marked as Convex. Therefore, they are most useful for background objects like environment geometry. Convex $$anonymous$$esh Colliders must be fewer than 255 triangles.
Egro, the best way to do object (non-environmental) physics is by using a primitive collider- either by wrapping it in a single large collider (easier but less accurate) or using compound colliders (somewhat more accurate depending on the level of detail.
Interestingly, I was also doing some research on Unity colliders and the "wrapper" collider for actors seems to be the popular choice even among the higher-grade games. Consequently, one gets actors able to go into walls (where the model leaves the wrapper collider) but not quite through it, but this is considered acceptable.
TL;DR leave the convex mesh for backgrounds.
you're talking about the character collider, right? Using a character collider for collision with the world makes tons of sense, since we don't want to get stuck anywhere, also we want always to be able to rotate. that the model goes through the wall can be prevented, you could make the character collider bigger than the model, you could even grow the character collider or grow another collider if he stretches out an arm or something.
for stuff like bullets though we can use mesh colliders again (I think people use simplified collision meshs for models with high detail), now we can use raycast or a sphere collider vs mesh collider.
So I think one character should have different colliders for different tasks, like a sphere trigger for pickups, a mesh collider to test against bullets, a character collider to test vs the levelgeometry.
Answer by Sun-Dog · Jan 30, 2013 at 12:47 AM
I would suggest that your car is made of a series of separate meshes, each mesh has a convex mesh collider on it and each mesh object has its own rigidbody.
I would suggest that you look at the Rigidbody Component docs and look at the section on child colliders. I would suggest that you only want one rigidbody on the root GameObject, keep the meshes to themselves and have a series of child colliders.
Regardless of what you choose to do with your colliders, you should only have one rigidbody for the car and it should go on the root.
Your answer