I’m using Unity 2020.1.6f1, the Oculus plugin and the XR Toolkit and really the only thing that absolutely is a no go for my game is the extreme lag/stutter I experience when moving the player. Can’t have a handgun going haywire in a shooter game, now can we?
I wasn’t able to find out if this is a specific problem I’m facing (f.e. because I use the “wrong” version of Unity) or if this is a XR Toolkit problem. Grabbing and playing around with objects is smooth and how I would like it, but as soon as I’m walking, the grabbed object is lagging extremely.
Any ideas or suggestions would be highly appreciated!
I was just going to post a question about this. Instantaneous is smooth as butter, but velocity tracking is all over the place. I tried the same settings provided in the sample projects provided by Unity and everything is a bit smoother if I stand still, BUT as soon as I start moving, the interactable is a jittery mess.
Maybe I’m asking for too much, but it would be so nice to get that Half Life Alyx level of physics.
The reason this happens is because velocity tracking using the physics engine to move the object (via velocity) but the normal movement systems move the player via transfoms. A simple way to allievate this is to make the object a child of the XR rig when selected. A more complex, but proper solution is to create a physics based locomotion system.
If you want high-quality, VR physics you’ll have to roll your own locomotion and grabbing systems. It’s a rabbit-hole but worth going down. Be prepared for a lot of quaterion and vector math though.
I just tried @TheMaximL 's suggestion and it worked beautifully. I created a new class specifically for object’s I want to be velocity tracked, and replaced the XRGrabInteractable component on those GameObjects.
Here’s my implementation:
using UnityEngine.XR.Interaction.Toolkit;
public class XRGrabVelocityTracked : XRGrabInteractable
{
protected override void OnSelectEntered(XRBaseInteractor interactor)
{
SetParentToXRRig();
base.OnSelectEntered(interactor);
}
protected override void OnSelectExited(XRBaseInteractor interactor)
{
SetParentToWorld();
base.OnSelectExited(interactor);
}
public void SetParentToXRRig()
{
transform.SetParent(selectingInteractor.transform);
}
public void SetParentToWorld()
{
transform.SetParent(null);
}
}
Thanks a lot for sharing this. It sure fixes the stuttering issue! But unfortunately when I do this, it looks like the pivot point for my gun isn’t working anymore. I use the pivot point (empty gameobject) in the Attach Transform of the XR Grab Interactable. Any idea of how to fixe this?
This didn’t seem to work for me at all with VelocityTracking. Only with Kinematic. Do you need to use any of the other smoothing settings to get VT to work?