Reacting to what's in the XR Socket

I am trying to create a puzzle where depending on what object you place on a pedestal the environment changes. I have all of the code working for moving the objects the only thing I can’t get working is to find the object that is in the XR Socket Interactor.

Does anyone know the code or a method to assign the object in the XR Socket to a GameObject so I can pass it to my scripts to process?

You can get the selectTarget property of Socket Interactor to see which Interactable object is currently grabbed by it.

1 Like

Thank you for the advice. I’ve had a look into implementing the SelectTarget to get the current object but I can’t use the returned value. Is there a way to convert the XRBaseInteractable value to a GameObject or a way to access the selected object to pull values from it?

XRBaseInteractable is a monobehaviour. If you want access to its gameObject just use var selectedGameObject = mySocket.selectTarget.gameObject;
This does assume that you have checked that selectTarget isn’t null.

I was struggling to find a way to convert types to GameObject and that works perfectly.
Thank you very much for your help.