- Home /
Rigidbody Collision?
Hello there, Well its pretty easy i think so lets start with what i have:
A level: this is a model imported from Maya with a Mesh Collider
A vehicle: this also is a model from Maya which is imported and has a Mesh Collider
Now what im trying to do is add physics to the vehicle so i added a Rigidbody (i do not know if this was the right thing to do though)
And when i played my scene the vehicle starts to fall and falls straight trough the level without any kind of collision.
What i was expecting is that it would hit the level and just stop there because it has colliders, also i tried this with the FPSWalker component, and that did work, though i want a physics object and not the FPSWalker.
Could anyone please explain me what i am doing wrong or give me some directions on how i can have my physics object collide correctly?
Greetings, TheMPC
Answer by spinaljack · Apr 20, 2010 at 02:17 PM
Instead of using a mesh collider for the car use box colliders to approximate the shape, this is not only faster but also more accurate for fast car simulations.
Make sure that the terrain has a mesh collider, sometimes just importing a mesh doesn't give you any colliders. Click on the level, click on component > physics > mesh collider, it should appear as a component, the mesh variable should say the name of your mesh and the project view will show a wire frame of the mesh collider, if not it's not worked properly and you need to pick a mesh to drag into the slot. Have you tried creating a unity terrain instead? You can import your buildings and things to go on top of it.
Generally speaking with driving games it's best not to use thin colliders like lamp posts as your car can get stuck in them at high speeds. Here's a section on wheel colliders, wheel colliders can help you simulate things like wheel slip.
Here is a tutorial for a driving game that uses wheel colliders
Thank you for the helpfull information, will reply beack to this post once i tested the sollution tomorrow.
I'd like to add a related newbie question: Using $$anonymous$$esh Colliders for level objects and a character controller for the player, I am currently walking (translating) through walls. Is this correct behaviour?
Should I use CharacterController.$$anonymous$$ove ins$$anonymous$$d of Transform.Translate for player movement? And what about mobs/enemies? What colliders / movement function should they use?
Thank you and apologies for the triviality of my question...