Search Unity

Locomotion checks

Discussion in 'AR/VR (XR) Discussion' started by stychu, May 14, 2020.

  1. stychu

    stychu

    Joined:
    May 9, 2016
    Posts:
    62
    What will be the best practice to check for locomotion?? Are those extra checks in the second example worth??

    1)

    Code (CSharp):
    1. private void StartTurn(Vector2 position)
    2.     {
    3.         float rotation = turnSpeed * position.x;
    4.  
    5.         if (Math.Abs(rotation) <= Mathf.Epsilon) return;
    6.        
    7.         XRRig xrRig = system.xrRig;
    8.        
    9.         if (xrRig)
    10.             xrRig.RotateAroundCameraUsingRigUp(rotation);
    11.     }
    2)
    Code (CSharp):
    1. private void StartTurn(Vector2 position)
    2.     {
    3.         if (!CanBeginLocomotion())
    4.             return;
    5.        
    6.         float rotation = turnSpeed * position.x;
    7.  
    8.         if (Math.Abs(rotation) <= Mathf.Epsilon && !BeginLocomotion()) return;
    9.        
    10.         XRRig xrRig = system.xrRig;
    11.        
    12.         if (xrRig)
    13.             xrRig.RotateAroundCameraUsingRigUp(rotation);
    14.  
    15.         EndLocomotion();
    16.     }