Search Unity

Question How to assemble two prefabs runtime?

Discussion in 'Prefabs' started by sterbilly, Dec 3, 2022.

  1. sterbilly

    sterbilly

    Joined:
    Oct 10, 2022
    Posts:
    7
    At the moment, I have two prefabs: a seat and a leg. Both have mesh collider convex, and the seat has a socket where I have to place the leg. It works, but when I release the seat with the leg assembled, only the seat collide with the floor, while the leg pass through the floor (and the others object, like a table). The final result I want is a chair (a seat and four leg). How can I stop the leg from to pass through the floor when is attached to the seat?
     
  2. alexsmith123

    alexsmith123

    Unity Technologies

    Joined:
    Jan 11, 2022
    Posts:
    27
    Hi,
    Could you please show your script on the legs? Is there any difference between how you handle the legs and the seat?
    In the mean time here is an overview on collision, I hope it helps.
     
  3. alexsmith123

    alexsmith123

    Unity Technologies

    Joined:
    Jan 11, 2022
    Posts:
    27
    One more thought: Do you have a Rigidbody on it?
     
  4. sterbilly

    sterbilly

    Joined:
    Oct 10, 2022
    Posts:
    7
    There isn't difference between how I handle legs and seat. I'm using the XR Interaction Toolkit, I haven't my script. And yes, both have rigid body and mesh colliders. The problem happen only when the leg is attached to the seat, otherwise the physics on the leg works right and it collides with the others objects in the rooms.
     
  5. VRDave_Unity

    VRDave_Unity

    Unity Technologies

    Joined:
    Nov 19, 2021
    Posts:
    277
    Hi @sterbilly
    Can you post an image of your setup for the objects? That could help us see what's going on and where it may not be configured correctly.
     
  6. sterbilly

    sterbilly

    Joined:
    Oct 10, 2022
    Posts:
    7
    This is the setup
     

    Attached Files: