Search Unity

Resolved Grabbing an object teleports its center to my controller (how to offset grab)

Discussion in 'XR Interaction Toolkit and Input' started by Estrambord, Mar 8, 2021.

  1. Estrambord

    Estrambord

    Joined:
    Nov 20, 2018
    Posts:
    2
    I'm having trouble with the XRGrabInteractable script. When I grab an object (let's say a cube), the center of the grabbed object teleports on the transform of my controller.
    I'd like to be able to grab the cube from anywhere (say a corner) and not having its center come to my controller, keeping the offset distance between the center of the cube and the Attach Transform. I only want the cube to translate, no rotations involved so it should be easier (only need to add an offset to the position of the controller) but I can't find a way to do it.
    I thought about overriding some functions in the XRGrabInteractable script (like the GetWorldAttachPosition), but since I'm a beginner in C# coding I might be doing that wrong.
    Does anyone have an idea ? Thanks in advance !
     
  2. Estrambord

    Estrambord

    Joined:
    Nov 20, 2018
    Posts:
    2
    I kept on searching and found a video explaining exactly what I want, I'll leave it here for anyone wondering how to offset grab an object

     
    xajax, SamuelRodri and Dimii79 like this.