|
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.
(comments are locked)
|
|
OK, so I'm going to "answer" this problem by declaring it unsolvable. If anyone knows I'm wrong, by all means, please post a correction.
(comments are locked)
|
|
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.
" If you want to assign part of the collider to a part of the mesh you can just adjust the colliders itself." Thank you for the extended answer. I appreciate your taking the time to be so thorough. For some reason your last sentence isn't making sense to me. What do you mean by "assign part of the collider to the mesh"? When I create a new box collider, it moves all right, only without the mesh. I'm not sure how I "hook" the mesh onto it.
Aug 30 '12 at 10:38 PM
MP0732
Ok so this is actually a bit of a parenting problem that you seem to be having. What I said for the last sentence was meaning the parameters on the mesh script in the inspector. It seems like you have the Box Collider added to a parent object and are moving the child object. You best bet is to add the collider to the raw mesh object (the actual mesh). -Devon
Aug 31 '12 at 01:23 AM
Devon Hall
OK, but the raw mesh object is the entire house. I only want the door to move. Won't I just end up moving the entire house back and forth instead of just the door?
Aug 31 '12 at 01:54 AM
MP0732
(comments are locked)
|
|
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. Well, I want the door's collider to be there. When the door is closed, after all, the player shouldn't be able to pass through it. I just want the collider to move with the door when it opens. So, I'm not sure how deleting the door's collider would help. Also, I don't think I can do that. The collider is assigned to the model's mesh, not the door's. That's precisely the problem. I don't know how to assign a collider to just one part of the mesh (e.g. the door) without assigning it to the entire mesh (i.e. the model).
Aug 29 '12 at 02:19 AM
MP0732
Now you have a bare bone box collider for your door and it swings with it.
Aug 29 '12 at 03:28 AM
Sundar
(comments are locked)
|
|
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...). I'm using keyframe animation (no bones) from Daz 3D. I don't know if Daz 3D animates via vertex animation. Actually, I'm not sure I understand what vertex animation is.
Aug 29 '12 at 02:20 AM
MP0732
Vertex Animations are animations based on morph targets. You have multiple, slightly different versions of a model and one master model. The master model can be morphed to look like any of the target models and animated between the different states. Is used mainly for face animations.
Aug 29 '12 at 10:35 AM
Piflik
OK, thanks Piflik. I guess I don't know then what Daz uses.
Aug 29 '12 at 09:28 PM
MP0732
Well...you should be able to figure out the important bit in Unity: If you look at your mesh in Unities Project Tab, is ist a little hierarchy with sub meshes (Door, Door Frame, handle or bone objects), or is it just one single mesh? In the first case, you should be able to identify the object/bone that represents the door and any component you add to this object/bone will follow its animation. Put a collider there and you should be able to walk through the door, when it's open, but not, when it's close.
Aug 29 '12 at 09:43 PM
Piflik
Sorry for the delay. I can only work on this after my paying job. As to your question, yes, the problem is that the mesh itself is one. There are no sub meshes. If I understand you correctly, I need to figure out how to create sub meshes, is that right?
Aug 30 '12 at 10:31 PM
MP0732
(comments are locked)
|
