Search Unity

Resolved XRGrabInteractable (VelocityTracking): Massive lag/stutter when moving player

Discussion in 'XR Interaction Toolkit and Input' started by MentalGames, Oct 23, 2020.

  1. MentalGames

    MentalGames

    Joined:
    May 2, 2016
    Posts:
    40
    Hey partypeople,

    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! :)
     
  2. bobby2dazzler

    bobby2dazzler

    Joined:
    Nov 7, 2020
    Posts:
    2
    Me too. And same when throwing objects. Would love sime help :)
     
  3. CassieNova

    CassieNova

    Joined:
    Oct 25, 2020
    Posts:
    8
    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. :)
     
    MentalGames likes this.
  4. FishStickies94

    FishStickies94

    Joined:
    Jul 27, 2019
    Posts:
    70
    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.
     
    Geouug, CassieNova and MentalGames like this.
  5. Geouug

    Geouug

    Joined:
    Feb 13, 2018
    Posts:
    3
    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:
    Code (CSharp):
    1. using UnityEngine.XR.Interaction.Toolkit;
    2.  
    3. public class XRGrabVelocityTracked : XRGrabInteractable
    4. {
    5.     protected override void OnSelectEntered(XRBaseInteractor interactor)
    6.     {
    7.         SetParentToXRRig();
    8.         base.OnSelectEntered(interactor);
    9.     }
    10.  
    11.     protected override void OnSelectExited(XRBaseInteractor interactor)
    12.     {
    13.         SetParentToWorld();
    14.         base.OnSelectExited(interactor);
    15.     }
    16.  
    17.     public void SetParentToXRRig()
    18.     {
    19.         transform.SetParent(selectingInteractor.transform);
    20.     }
    21.  
    22.     public void SetParentToWorld()
    23.     {
    24.         transform.SetParent(null);
    25.     }
    26. }
    27.  
     
  6. SmithySFC

    SmithySFC

    Joined:
    Jan 15, 2021
    Posts:
    11
    THANKS SO MUCH FOR THIS!!!!
     
  7. Bender_R

    Bender_R

    Joined:
    May 21, 2018
    Posts:
    115
    Hi there,

    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?

    Thanks a lot!!

    Cheers
     
  8. BulletproofE

    BulletproofE

    Joined:
    Aug 8, 2020
    Posts:
    1
    Hey did you figure this out same thing for me?
     
  9. Bender_R

    Bender_R

    Joined:
    May 21, 2018
    Posts:
    115
    Nope... Haven't found fix for this..
     
  10. KineticBen

    KineticBen

    Joined:
    Jul 19, 2021
    Posts:
    10
    Parenting the object to the XR rig itself, rather than the interactor object worked for me :)
     
  11. Widanon

    Widanon

    Joined:
    Jan 31, 2021
    Posts:
    36
    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?
     
  12. roman_prusakevich

    roman_prusakevich

    Joined:
    Aug 20, 2020
    Posts:
    1
    I disabled Position Tracking in XR Grabbable, instead I update position via script when "OnSelectEntered" event is called . Screenshot 2022-08-21 at 9.48.34 AM.png Screenshot 2022-08-21 at 9.51.23 AM.png
     
  13. Davidc4ke

    Davidc4ke

    Joined:
    Sep 23, 2022
    Posts:
    1
    Hi Roman, could you send the full script you used for this? I am not sure I understand from the snippet alone.
     
  14. Christian_Perri

    Christian_Perri

    Joined:
    Aug 7, 2022
    Posts:
    31
    i am trying to set the controller as a child of the XR origin,but i have still the problem
     
  15. Christian_Perri

    Christian_Perri

    Joined:
    Aug 7, 2022
    Posts:
    31
    How did you do?