prefab, colliders and parenting

Hello guys,
in the picture attached there is a prefab I made consisting in:

  • DisplayCase
  • shelf 1 top;
  • shelf 2 middle;
  • shelf 3 bottom;

so all the shelves have a box collider and they are parented to the displaycase (in transparency). The problem I have is that if I attach a collider to the partent, well I lose all the colliding properties on the shelves. So i wonder what could be the solution. I need to pick objects (like the vases) which have their own collider, and then put them into the case which should shut the colider off for a while and then on again for when i want to pick the display case up and move it together with all the objects inside.

Hope that’s clear.
Many thanks for any suggestion.
GC. :sunglasses:

The colliders inside are basically turned off because PhysX determines that the collider of the case prevents collisions from reaching the contained colliders.

To set up collision correctly for your case, you’ll need to create multiple colliders for it - one thin box per surface. Preferably don’t make these too thin, as you’d want to give PhysX some buffer space for detecting collisions with fast moving objects.

Uhm, so let me guess, every shelves have its own box collider, and that’s fine (I guess). For the DisplayCase the trick would be to create a BoxCollider which is smaller that the real dimensions of the case itself? right?

Not really. Imagine your case is a box - you’re creating a collider for each of the six surfaces of the box - not a collider containing the entire case.

Ahh
uhm… ouch … the problem is that I am importing my case as an .OBJ file which doesn’t let Unity3D to distinguish inbetween the faces :frowning:

You don’t have to. Just create the colliders on child GOs of your main case GO.

Or make the shelves one object and the outside frame a separate object. When you import them, turn on the mesh collider for the shelves and off for the frame. Mesh colliders (as I recall) have a higher performance hit than box colliders, but in a simple scene like this it should work fine.

Sorry, may be I didn’t explained myself:

all the components of the prefab are different geometries assembled in Unity. So the shelves and the cabinet are different objects. The Vases have a boxColider, the shelves have boxcollider, but If I put a meshColider on my cabinet, this won’t let me put my objects inside the cabinet as meshColiders colides with boxColider.

Get rid of your mesh collider on your cabinet and add thin box colliders for each pain of glass and shelf you are wanting to have a physical presence. An object can contain multiple colliders.

Right. Then if you want physics to interact with what is inside the cabinet, then you’ll need to create separate colliders for the sides of the cabinet as Ant suggested.

Re-reading your initial issue, it’s not clear if your problem is with physics or the ability to initiate the dragging of rigid bodies.
Are you using the DragRigidBody script? If so the script initiates a ray that is fired in to space from the camera using the mouse x,y and then uses the hitresult to instatiate a drag. It is possible through the use of layers to exclude rigid bodies from the mousepick process via a layermask.

Maybe as a workaround solution you could have a base to your cabinet which is where the box collider is located to enable you to drag the cabinet around. The top part of the cabinet would be open - although visually you will still be rendering the mesh. This would allow you to drag items on to the shelves…

All right! :)) I didn’t … I guess I understand now. (Hopefully) It’s Xmas almost, so my brain is in a festive mood :slight_smile:

Thanks you all guys!

Well, the problem I have is the missing interaction with the DragRigidbody.js and the cabinet. And first I know that’s it wouldn’t work as the cabinet initially hadn’t any collider, but now I need to move my cabinet, no matters what will happen to the objects. So the cabinet can’t have as many BoxColider as I wish as Unity3D doesn’t allow it. And as each objects (the vases) have a box collider, those colliders will interact with the cabinet collider if that is a boxCollider, so it will avoid me to put the vases on the inner shelves.

So, I can put vases on the shelves if the cabinet has NO collider (so far), but the shelves have a box collider.
Then… I created a box collider for the bottom of my cabinet, but for whatever reason DragRigidBody, doesn’t interact with it! GRRR!!!