XR Controller Recorder ... how to use it?

Hi,
I’m trying to use XRControllerRecorder component, but when I play the recorded animation, the controller is being moved using a differente coordinate system. it seems to me that the recorder doesn-t record the absolute position of the controller.
Anyone have the same problem?
For those interested, these are my steps to record a simple interaction:

  • Create a XRControllerRecording asset
  • Add a XRControllerRecorder component on RightHandController GameObject, under XRig root
  • Link the XRController component and the XRControllerRecording asset to the public field of XRControllerRecorder component.

Where am I wrong?
Thank you

I was wondering the same, it’s a mystery!

1 Like

According to the source code it just saves the XRController.transform.position/rotation and then replays it.
Can you provide the code you used?

I used only the XRControllerRecorder and followed the steps I wrote in my first post. No code required.
It really actually saves pos/rot of the XRController transforms, but it seems to not take into account also the XRRig pos/rot, so it seems quite useless right now.

1 Like

You can also take a look into one of the tests in the XR Interaction toolkit package itself. Here is a small Snippet from Tests/Runtime/DirectInteractorTest.cs

[UnityTest]
public IEnumerator DirectInteractorCanSelectInteractable()
{
    TestUtilities.CreateInteractionManager();
    var interactable = TestUtilities.CreateGrabInteractable();
    var directInteractor = TestUtilities.CreateDirectInteractor();
    var controller = directInteractor.GetComponent<XRController>();
    var controllerRecorder = TestUtilities.CreateControllerRecorder(controller, (recording) =>
    {
        recording.AddRecordingFrame(0.0f, Vector3.zero, Quaternion.identity,
         true, false, false);
        recording.AddRecordingFrame(float.MaxValue, Vector3.zero, Quaternion.identity,
         true, false, false);
    });
    controllerRecorder.isPlaying = true;

    yield return new WaitForSeconds(0.1f);

    Assert.That(directInteractor.selectTarget, Is.EqualTo(interactable));
}
1 Like