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?
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 Mesh 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.Move instead 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...
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
No one has followed this question yet.
Raycast doesnt detect object in front of rigidbody (player is stuck on wall)
Change bounciness at runtime
Limit How Far an Object is Pushed After a Collision
Is it possible to tell Unity physics to ignore a collision at collision time?
Checking collisions between two objects that don't have rigidbodies