Search Unity

Question Objects rotating when picked up

Discussion in 'XR Interaction Toolkit and Input' started by blkkap, Mar 9, 2023.

  1. blkkap

    blkkap

    Joined:
    Jan 13, 2023
    Posts:
    3
    Hello all,
    I'm new to posting on unity forums so please forgive me if I'm in the wrong forum.

    I've been working on a side project for a few weeks and now I'm having an issue with one object. When I go to pick it up instead of it being vertical when I pick it up it goes horizontal so its laying on its side with the opening looking away from me. The object is a beaker which was imported from blender as a fbx file I mapped out all the textures and reset the rotation and scale before importing it.
    beaker.png
    beakerFOLDer.png
    the components I have on the beaker are rigid body, capsule collider, and XR grab interactable. Ill post pictures how I have those set up. The components are only on the 150 ml beaker child


    two.png



    xr.png


    Nothing other than adding those three components has been done to this object. If anyone has any ideas of how I can resolve the issue id greatly appreciate it

    Thanks
     
  2. Doc_Martins

    Doc_Martins

    Joined:
    Jun 1, 2020
    Posts:
    14
    Shortly, using an Attach Transform could fix your issue. This means:
    • adding an empty Game Object as a child of "Beaker 150ml"
    • setting up this empty object's position and rotation so that the Y axis points up and (I assume) the Z axis points in the same direction as the spout
    • assigning this transform to the field "Attach Transform" in the XR Grab Interactable
    This assumes that you Grab Interactor on the Controller does not have a custom Attach Transform too - you can check that just to be sure.

    A different way to go about this is to not use the model "Beaker 150ml" as the base object itself, but rather:
    • create a Game Object called "Beaker Base" for instance
    • adding a "Beaker 150ml" as a child of "Beaker Base" and align it to the parent to get the desired rotation
    • add the Collider, Rigidbody and XR Grab Interactable to "Beaker" instead of "Beaker 150ml"
    This effectively isolates the "visual" part of the whole object from the physics/grab logic. You can align the "visual part" as necessary to make up for the 3D model's pivot (and you have to update your Collider after). When grabbed, the rotation and position is determined by the "Beaker Base"; but you could also create an Attach Transform as above.
     
    VRDave_Unity likes this.
  3. VRDave_Unity

    VRDave_Unity

    Unity Technologies

    Joined:
    Nov 19, 2021
    Posts:
    275
    Hey @blkkap, what @TMS_Martins posted is one of the recommended ways to solve this issue. You can also enable the
    Use Dynamic Attach
    checkbox located below the Attach Transform field. This will preserve the position and rotation at the point of the grab.
     
  4. blkkap

    blkkap

    Joined:
    Jan 13, 2023
    Posts:
    3