x


Player walks through imported model

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.

more ▼

asked Aug 29 '12 at 12:07 AM

MP0732 gravatar image

MP0732
44 4 12 24

(comments are locked)
10|3000 characters needed characters left

4 answers: sort voted first

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.

more ▼

answered Sep 08 '12 at 05:49 PM

MP0732 gravatar image

MP0732
44 4 12 24

(comments are locked)
10|3000 characters needed characters left

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 Collide`r 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.
more ▼

answered Aug 29 '12 at 10:41 AM

Devon Hall gravatar image

Devon Hall
184 1 5

" 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

I just read this thread, which makes me think this problem is only solvable if sub meshes and therefore bones already exist. Since this model didn't come with them, I'm wondering if I'm just out of luck.

Aug 31 '12 at 02:01 AM MP0732
(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered Aug 29 '12 at 12:46 AM

Sundar gravatar image

Sundar
581 2 2

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
  • Create a box collider.
  • Make it a child for the door
  • Adjust the size of box collider same as door using scale
  • Remove mesh renderer component from the box collider

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)
10|3000 characters needed characters left

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...).

more ▼

answered Aug 29 '12 at 12:59 AM

Piflik gravatar image

Piflik
5.4k 15 26 44

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)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3768
x1682

asked: Aug 29 '12 at 12:07 AM

Seen: 388 times

Last Updated: Sep 08 '12 at 05:49 PM