Add delay to hand tracking with XR Interaction Hands

Hi there,

As part of a psychological experiment I would like to add a small but noticeable delay to visual feedback of the XR hands movement. That is, someone moves their real hand, but movement of the virtual hand is delayed by 500ms. Is this possible to do and what would be the best way to go about it?

Thanks for any insight!

It’s possible to do it, but you will have to code it. As far as i know, there isn’t a built-in function for that, a game developer will never want to do this :sweat_smile:.

I suggest you look at the Unity XR Hands package, and the sample “HandVisualizer”.

The script HandVisualizer.cs is a good starting point. Have a look at how it gets the hand data from the HandSubsystem.

You will have to create a Queue that save tuples (current timestamp, XRHand data).

In an update method, you will need to check if the first queue element timestamp + your delay is greater than the current timestamp (use Peek). If yes, Dequeue the tuple and feed the XRHand data to the hand model.

As an alternative, have a look at the “TrackedPoseDriver” objects (Aim Pose and Pinch Grab Pose). You could create your own version of the TrackedPoseDriver class, and in UpdateCallback add positions and rotations to a queue as suggested above.

Then you could dequeue in PerformUpdate as needed.

@RT508 : A great place to start would be implementing an IXRHandProcessor. There is an example one in the same HandVisualizer sample package suggested that @Pitou22 made. The file is located in Samples/XR Hands/1.5.0/HandVisualizer/Scripts/HandProcessor.cs. It’s a good starting point if you want to introduce modification of the joints as they come through the subsystem but before they are used by the visual/physics scripts.