I checked the answers on this thread, but unfortunately, none of them has worked. Even after adding Component/Mesh/Mesh Renderer and Component/Physics/Mesh Collider to the model in the hierarchy, the player can still walk through its walls.
I have also used the mesh collider under the model’s prefab in the Project window and dragged the prefab’s mesh collider onto the model’s instance in the Hierarchy window. Once I do this, the player can no longer walk through the model’s walls, indicating that the model’s colliders have been generated.
The problem with this approach is that when the I open the model’s doors via animation, the door’s collider doesn’t move, which prevents the player from entering into what looks like an open door.
So, I’m thinking that using the prefab’s mesh collider is having some side-effect I don’t understand. Is there some other, better way to created colliders for the model that will move with, say, the animated door? Thanks in advance.
In the inspector select your mesh, then select the door which will be the child of your mesh, if they are, delete only door’s mesh collider component. Now you are free to pass through the door.
What kind of animatiin are you using? Keyframes in Unity or exported bone based animation? In both cases it should be possible to attach a collider component to the moving element, in the worst case by parenting an Empty to the door. Vertex based animations are a diiferent matter, though (but I don’t even know if Unity can import those…).
So in Unity3D you have to have colliders for objects to appear as solid.
Colliders do basically as said in the name itself.
The detect collisions. Colliders inherit the fact that they aren’t able to be passed through unless, in the inspector you check the box for ‘is trigger’ but usually you won’t have to use that unless you actually know what you are using it for. Documentation for colliders are found here: http://docs.unity3d.com/Documentation/ScriptReference/Collider.html
But they can be a little vague in the explaining portion or kind of hard to explain.
So in Unity if you create a box from the Create Object → Box you see if you click on the box it has the ‘Box Collider’ on it. Colliders don’t allow other colliders to pass through them. So your player, having a ‘Capsule Collider’ cannot pass through the actual box itself.
When you import a model (from say
Blender, 3DS Max, Sketchup, Maya
etc.) you export a mesh. The mesh is
the actual object in which has a
‘Mesh Renderer’ on it. So if you
double click in the scene view the
object that you have imported and
then goto the menus then under Components -> Physics -> Box Collider while having the mesh
selected (By double click it) it will
add a box collider to it, you can add
other colliders to mess around with
but generally box colliders work for
doors (since they are rectangular).
So in the inspector you can adjust
the box collider’s
attributes/variables to what you need
for the door. If you want to assign
part of the collider to a part of the
mesh you can just adjust the
colliders itself.