Cant get Attach Transform of interactorObject.

I was following this tutorial: Simple Offset Interactable for XR Toolkit (Update) - YouTube
Code:

`
using UnityEngine;
using UnityEngine.XR.Interaction.Toolkit;

public class OffsetInteractable : XRGrabInteractable
{
protected override void OnSelectEntering(SelectEnterEventArgs args)
{
base.OnSelectEntering(args);
MatchAttachPoint(args.interactor);
}

private void MatchAttachPoint(XRBaseInteractor interactor)
{
    bool isDirect = interactor is XRDirectInteractor;
    attachTransform.position = isDirect ? interactor.attachTransform.position : transform.position;
    attachTransform.rotation = isDirect ? interactor.attachTransform.rotation : transform.rotation;
}

}
`

And everything works just fine but it says that args.interactor is Obsolete and instead interactorObject should be used.
Even though it works fine like this, I didn’t want to have an Obsolete method.

I tried using
private void MatchAttachPoint(IXRInteractor interactor) { bool isDirect = interactor is XRDirectInteractor; attachTransform.position = isDirect ? GetAttachTransform(interactor).position : transform.position; attachTransform.rotation = isDirect ? GetAttachTransform(interactor).rotation : transform.rotation; }

and
private void MatchAttachPoint(IXRInteractor interactor) { bool isDirect = interactor is XRDirectInteractor; Transform GrabTransform = GetAttachTransform(interactor); attachTransform = isDirect ? GrabTransform : transform; }

but couldn’t achieve the desired effect as shown in the video.

It’s also said in Unity docs that IXRInteractor interactorObject should be used instead of XRBaseInteractor interactor.
https://docs.unity3d.com/Packages/com.unity.xr.interaction.toolkit@2.0/api/UnityEngine.XR.Interaction.Toolkit.BaseInteractionEventArgs.html
https://docs.unity3d.com/Packages/com.unity.xr.interaction.toolkit@2.0/api/UnityEngine.XR.Interaction.Toolkit.XRBaseInteractable.html

Any help appreciated

Hey, I just figured it out:
first, you’re gonna have to use “SelectEnterEventArgs args” and “SelectExitEventArgs args” respectively in all of the functions.
In the 2.0.0+ versions of the XR toolkit, they refer to the selection of an object as an “event object” which means the “args” will contain both your interactor and your interactable (the “hand” and the selected element).

now, every time you need to refer to the Attach Point between the interactor and the interactable you can use this: args.interactorObject.GetAttachTransform(args.interactableObject)

(continuing with either .position / .localposition or .rotation / .localrotation)

the rest of the script remains pretty much the same.

I’ll attach my complete updated script as a TXT file [195662-graboffset.txt|195662]

,Hey, I just figured it out:
first, you’re gonna have to use “SelectEnterEventArgs args” and “SelectExitEventArgs args” respectively in all of the functions.
In the 2.0.0+ versions of the XR toolkit, they refer to the selection of an object as an “event object” which means the “args” will contain both your interactor and your interactable (the “hand” and the selected element).

now, every time you need to refer to the Attach Point between the interactor and the interactable you can use this: args.interactorObject.GetAttachTransform(args.interactableObject)

(continuing with either .position / .localposition or .rotation / .localrotation)

the rest of the script remains pretty much the same. I’ll attach my complete updated script as a TXT file [195662-graboffset.txt|195662].