Advertisement
Guest User

Untitled

a guest
Sep 15th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 19.06 KB | None | 0 0
  1. /************************************************************************************
  2.  
  3. Copyright   :   Copyright 2017 Oculus VR, LLC. All Rights reserved.
  4.  
  5. Licensed under the Oculus VR Rift SDK License Version 3.4.1 (the "License");
  6. you may not use the Oculus VR Rift SDK except in compliance with the License,
  7. which is provided at the time of installation or download, or which
  8. otherwise accompanies this software in either electronic or hard copy form.
  9.  
  10. You may obtain a copy of the License at
  11.  
  12. https://developer.oculus.com/licenses/sdk-3.4.1
  13.  
  14. Unless required by applicable law or agreed to in writing, the Oculus VR SDK
  15. distributed under the License is distributed on an "AS IS" BASIS,
  16. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. See the License for the specific language governing permissions and
  18. limitations under the License.
  19.  
  20. ************************************************************************************/
  21.  
  22. using System;
  23. using UnityEngine;
  24.  
  25. /// <summary>
  26. /// Controls the player's movement in virtual reality.
  27. /// </summary>
  28. [RequireComponent(typeof(CharacterController))]
  29. public class OVRCustomPlayerController : MonoBehaviour
  30. {
  31.     /// <summary>
  32.     /// The rate acceleration during movement.
  33.     /// </summary>
  34.     public float Acceleration = 0.1f;
  35.  
  36.     /// <summary>
  37.     /// The rate of damping on movement.
  38.     /// </summary>
  39.     public float Damping = 0.3f;
  40.  
  41.     /// <summary>
  42.     /// The rate of additional damping when moving sideways or backwards.
  43.     /// </summary>
  44.     public float BackAndSideDampen = 0.5f;
  45.  
  46.     /// <summary>
  47.     /// The force applied to the character when jumping.
  48.     /// </summary>
  49.     public float JumpForce = 0.3f;
  50.  
  51.     /// <summary>
  52.     /// The rate of rotation when using a gamepad.
  53.     /// </summary>
  54.     public float RotationAmount = 1.5f;
  55.  
  56.     /// <summary>
  57.     /// The rate of rotation when using the keyboard.
  58.     /// </summary>
  59.     public float RotationRatchet = 45.0f;
  60.  
  61.     /// <summary>
  62.     /// The player will rotate in fixed steps if Snap Rotation is enabled.
  63.     /// </summary>
  64.     [Tooltip("The player will rotate in fixed steps if Snap Rotation is enabled.")]
  65.     public bool SnapRotation = true;
  66.  
  67.     /// <summary>
  68.     /// How many fixed speeds to use with linear movement? 0=linear control
  69.     /// </summary>
  70.     [Tooltip("How many fixed speeds to use with linear movement? 0=linear control")]
  71.     public int FixedSpeedSteps;
  72.  
  73.     /// <summary>
  74.     /// If true, reset the initial yaw of the player controller when the Hmd pose is recentered.
  75.     /// </summary>
  76.     public bool HmdResetsY = true;
  77.  
  78.     /// <summary>
  79.     /// If true, tracking data from a child OVRCameraRig will update the direction of movement.
  80.     /// </summary>
  81.     public bool HmdRotatesY = true;
  82.  
  83.     /// <summary>
  84.     /// Modifies the strength of gravity.
  85.     /// </summary>
  86.     public float GravityModifier = 0.379f;
  87.    
  88.     /// <summary>
  89.     /// If true, each OVRPlayerController will use the player's physical height.
  90.     /// </summary>
  91.     public bool useProfileData = true;
  92.  
  93.     /// <summary>
  94.     /// The CameraHeight is the actual height of the HMD and can be used to adjust the height of the character controller, which will affect the
  95.     /// ability of the character to move into areas with a low ceiling.
  96.     /// </summary>
  97.     [NonSerialized]
  98.     public float CameraHeight;
  99.  
  100.     /// <summary>
  101.     /// This event is raised after the character controller is moved. This is used by the OVRAvatarLocomotion script to keep the avatar transform synchronized
  102.     /// with the OVRPlayerController.
  103.     /// </summary>
  104.     public event Action<Transform> TransformUpdated;
  105.  
  106.     /// <summary>
  107.     /// This bool is set to true whenever the player controller has been teleported. It is reset after every frame. Some systems, such as
  108.     /// CharacterCameraConstraint, test this boolean in order to disable logic that moves the character controller immediately
  109.     /// following the teleport.
  110.     /// </summary>
  111.     [NonSerialized] // This doesn't need to be visible in the inspector.
  112.     public bool Teleported;
  113.  
  114.     /// <summary>
  115.     /// This event is raised immediately after the camera transform has been updated, but before movement is updated.
  116.     /// </summary>
  117.     public event Action CameraUpdated;
  118.  
  119.     /// <summary>
  120.     /// This event is raised right before the character controller is actually moved in order to provide other systems the opportunity to
  121.     /// move the character controller in response to things other than user input, such as movement of the HMD. See CharacterCameraConstraint.cs
  122.     /// for an example of this.
  123.     /// </summary>
  124.     public event Action PreCharacterMove;
  125.  
  126.     /// <summary>
  127.     /// When true, user input will be applied to linear movement. Set this to false whenever the player controller needs to ignore input for
  128.     /// linear movement.
  129.     /// </summary>
  130.     public bool EnableLinearMovement = true;
  131.  
  132.     /// <summary>
  133.     /// When true, user input will be applied to rotation. Set this to false whenever the player controller needs to ignore input for rotation.
  134.     /// </summary>
  135.     public bool EnableRotation = true;
  136.  
  137.     protected CharacterController Controller = null;
  138.     protected OVRCameraRig CameraRig = null;
  139.  
  140.     private float MoveScale = 1.0f;
  141.     private Vector3 MoveThrottle = Vector3.zero;
  142.     private float FallSpeed = 0.0f;
  143.     private OVRPose? InitialPose;
  144.     public float InitialYRotation { get; private set; }
  145.     private float MoveScaleMultiplier = 1.0f;
  146.     private float RotationScaleMultiplier = 1.0f;
  147.     private bool  SkipMouseRotation = true; // It is rare to want to use mouse movement in VR, so ignore the mouse by default.
  148.     private bool  HaltUpdateMovement = false;
  149.     private bool prevHatLeft = false;
  150.     private bool prevHatRight = false;
  151.     private float SimulationRate = 60f;
  152.     private float buttonRotation = 0f;
  153.     private bool ReadyToSnapTurn; // Set to true when a snap turn has occurred, code requires one frame of centered thumbstick to enable another snap turn.
  154.  
  155.     void Start()
  156.     {
  157.         // Add eye-depth as a camera offset from the player controller
  158.         var p = CameraRig.transform.localPosition;
  159.         p.z = OVRManager.profile.eyeDepth;
  160.         CameraRig.transform.localPosition = p;
  161.     }
  162.  
  163.     void Awake()
  164.     {
  165.         Controller = gameObject.GetComponent<CharacterController>();
  166.  
  167.         if(Controller == null)
  168.             Debug.LogWarning("OVRPlayerController: No CharacterController attached.");
  169.  
  170.         // We use OVRCameraRig to set rotations to cameras,
  171.         // and to be influenced by rotation
  172.         OVRCameraRig[] CameraRigs = gameObject.GetComponentsInChildren<OVRCameraRig>();
  173.  
  174.         if(CameraRigs.Length == 0)
  175.             Debug.LogWarning("OVRPlayerController: No OVRCameraRig attached.");
  176.         else if (CameraRigs.Length > 1)
  177.             Debug.LogWarning("OVRPlayerController: More then 1 OVRCameraRig attached.");
  178.         else
  179.             CameraRig = CameraRigs[0];
  180.  
  181.         InitialYRotation = transform.rotation.eulerAngles.y;
  182.     }
  183.  
  184.     void OnEnable()
  185.     {
  186.         OVRManager.display.RecenteredPose += ResetOrientation;
  187.  
  188.         if (CameraRig != null)
  189.         {
  190.             CameraRig.UpdatedAnchors += UpdateTransform;
  191.         }
  192.     }
  193.  
  194.     void OnDisable()
  195.     {
  196.         OVRManager.display.RecenteredPose -= ResetOrientation;
  197.  
  198.         if (CameraRig != null)
  199.         {
  200.             CameraRig.UpdatedAnchors -= UpdateTransform;
  201.         }
  202.     }
  203.  
  204.     void Update()
  205.     {
  206.         //Use keys to ratchet rotation
  207.         if (Input.GetKeyDown(KeyCode.Q))
  208.             buttonRotation -= RotationRatchet;
  209.  
  210.         if (Input.GetKeyDown(KeyCode.E))
  211.             buttonRotation += RotationRatchet;
  212.     }
  213.  
  214.     protected virtual void UpdateController()
  215.     {
  216.         if (useProfileData)
  217.         {
  218.             if (InitialPose == null)
  219.             {
  220.                 // Save the initial pose so it can be recovered if useProfileData
  221.                 // is turned off later.
  222.                 InitialPose = new OVRPose()
  223.                 {
  224.                     position = CameraRig.transform.localPosition,
  225.                     orientation = CameraRig.transform.localRotation
  226.                 };
  227.             }
  228.  
  229.             var p = CameraRig.transform.localPosition;
  230.             if (OVRManager.instance.trackingOriginType == OVRManager.TrackingOrigin.EyeLevel)
  231.             {
  232.                 p.y = OVRManager.profile.eyeHeight - (0.5f * Controller.height) + Controller.center.y;
  233.             }
  234.             else if (OVRManager.instance.trackingOriginType == OVRManager.TrackingOrigin.FloorLevel)
  235.             {
  236.                 p.y = - (0.5f * Controller.height) + Controller.center.y;
  237.             }
  238.             CameraRig.transform.localPosition = p;
  239.         }
  240.         else if (InitialPose != null)
  241.         {
  242.             // Return to the initial pose if useProfileData was turned off at runtime
  243.             CameraRig.transform.localPosition = InitialPose.Value.position;
  244.             CameraRig.transform.localRotation = InitialPose.Value.orientation;
  245.             InitialPose = null;
  246.         }
  247.  
  248.         CameraHeight = CameraRig.centerEyeAnchor.localPosition.y;
  249.  
  250.         if (CameraUpdated != null)
  251.         {
  252.             CameraUpdated();
  253.         }
  254.  
  255.         UpdateMovement();
  256.  
  257.         Vector3 moveDirection = Vector3.zero;
  258.  
  259.         float motorDamp = (1.0f + (Damping * SimulationRate * Time.deltaTime));
  260.  
  261.         MoveThrottle.x /= motorDamp;
  262.         MoveThrottle.y /= motorDamp;
  263.         MoveThrottle.z /= motorDamp;
  264.  
  265.         moveDirection += MoveThrottle * SimulationRate * Time.deltaTime;
  266.  
  267.         // Gravity
  268.         /*
  269.         if (Controller.isGrounded && FallSpeed <= 0)
  270.             FallSpeed = ((Physics.gravity.y * (GravityModifier * 0.002f)));
  271.         else
  272.             FallSpeed += ((Physics.gravity.y * (GravityModifier * 0.002f)) * SimulationRate * Time.deltaTime);
  273.  
  274.         moveDirection.y += FallSpeed * SimulationRate * Time.deltaTime;
  275.        
  276.  
  277.         if (Controller.isGrounded && MoveThrottle.y <= transform.lossyScale.y * 0.001f)
  278.         {
  279.             // Offset correction for uneven ground
  280.             float bumpUpOffset = Mathf.Max(Controller.stepOffset, new Vector3(moveDirection.x, 0, moveDirection.z).magnitude);
  281.             moveDirection -= bumpUpOffset * Vector3.up;
  282.         }
  283.  
  284.         if (PreCharacterMove != null)
  285.         {
  286.             PreCharacterMove();
  287.             Teleported = false;
  288.         }
  289.         */
  290.         Vector3 predictedXYZ = Vector3.Scale((Controller.transform.localPosition + moveDirection), new Vector3(1, 1, 1));
  291.  
  292.         // Move contoller
  293.         Controller.Move(moveDirection);
  294.         Vector3 actualXYZ = Vector3.Scale(Controller.transform.localPosition, new Vector3(1, 1, 1));
  295.  
  296.         if (predictedXYZ != actualXYZ)
  297.             MoveThrottle += (actualXYZ - predictedXYZ) / (SimulationRate * Time.deltaTime);
  298.     }
  299.  
  300.  
  301.  
  302.  
  303.  
  304.     public virtual void UpdateMovement()
  305.     {
  306.         if (HaltUpdateMovement)
  307.             return;
  308.  
  309.         if (EnableLinearMovement)
  310.         {
  311.             bool moveForward = Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow);
  312.             bool moveLeft = Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow);
  313.             bool moveRight = Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow);
  314.             bool moveBack = Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow);
  315.             bool moveUp = Input.GetKey(KeyCode.Q);
  316.             bool moveDown = Input.GetKey(KeyCode.E);
  317.  
  318.             bool dpad_move = false;
  319.  
  320.             if (OVRInput.Get(OVRInput.Button.DpadUp))
  321.             {
  322.                 moveForward = true;
  323.                 dpad_move = true;
  324.  
  325.             }
  326.  
  327.             if (OVRInput.Get(OVRInput.Button.DpadDown))
  328.             {
  329.                 moveBack = true;
  330.                 dpad_move = true;
  331.             }
  332.  
  333.             MoveScale = 1.0f;
  334.  
  335.             if ((moveForward && moveLeft) || (moveForward && moveRight) ||
  336.                 (moveBack && moveLeft) || (moveBack && moveRight))
  337.                 MoveScale = 0.70710678f;
  338.  
  339.             /* No positional movement if we are in the air
  340.             if (!Controller.isGrounded)
  341.                 MoveScale = 1.0f;
  342.                 */
  343.  
  344.             MoveScale *= SimulationRate * Time.deltaTime;
  345.  
  346.             // Compute this for key movement
  347.             float moveInfluence = Acceleration * 0.1f * MoveScale * MoveScaleMultiplier;
  348.  
  349.             // Run!
  350.             if (dpad_move || Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
  351.                 moveInfluence *= 2.0f;
  352.  
  353.             Quaternion ort = transform.rotation;
  354.             Vector3 ortEuler = ort.eulerAngles;
  355.             ortEuler.z = ortEuler.x = 0f;
  356.             ort = Quaternion.Euler(ortEuler);
  357.  
  358.             if (moveForward)
  359.                 MoveThrottle += ort * (transform.lossyScale.z * moveInfluence * Vector3.forward);
  360.             if (moveBack)
  361.                 MoveThrottle += ort * (transform.lossyScale.z * moveInfluence * BackAndSideDampen * Vector3.back);
  362.             if (moveLeft)
  363.                 MoveThrottle += ort * (transform.lossyScale.x * moveInfluence * BackAndSideDampen * Vector3.left);
  364.             if (moveRight)
  365.                 MoveThrottle += ort * (transform.lossyScale.x * moveInfluence * BackAndSideDampen * Vector3.right);
  366.             if (moveUp)
  367.                 MoveThrottle += ort * (transform.lossyScale.y * moveInfluence * BackAndSideDampen * Vector3.up);
  368.             if (moveDown)
  369.                 MoveThrottle += ort * (transform.lossyScale.y * moveInfluence * BackAndSideDampen * Vector3.down);
  370.  
  371.  
  372.  
  373.             moveInfluence = Acceleration * 0.1f * MoveScale * MoveScaleMultiplier;
  374.  
  375. #if !UNITY_ANDROID // LeftTrigger not avail on Android game pad
  376.             moveInfluence *= 1.0f + OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger);
  377. #endif
  378.  
  379.             Vector2 primaryAxis = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick);
  380.             Vector2 secondaryAxis = OVRInput.Get(OVRInput.Axis2D.SecondaryThumbstick);
  381.  
  382.             // If speed quantization is enabled, adjust the input to the number of fixed speed steps.
  383.             if (FixedSpeedSteps > 0)
  384.             {
  385.                 primaryAxis.y = Mathf.Round(primaryAxis.y * FixedSpeedSteps) / FixedSpeedSteps;
  386.                 primaryAxis.x = Mathf.Round(primaryAxis.x * FixedSpeedSteps) / FixedSpeedSteps;
  387.                 secondaryAxis.y = Mathf.Round(secondaryAxis.y * FixedSpeedSteps) / FixedSpeedSteps;
  388.                 secondaryAxis.x = Mathf.Round(secondaryAxis.x * FixedSpeedSteps) / FixedSpeedSteps;
  389.             }
  390.  
  391.             if (primaryAxis.y > 0.0f)
  392.                 MoveThrottle += ort * (primaryAxis.y * transform.lossyScale.z * moveInfluence * Vector3.forward);
  393.  
  394.             if (primaryAxis.y < 0.0f)
  395.                 MoveThrottle += ort * (Mathf.Abs(primaryAxis.y) * transform.lossyScale.z * moveInfluence *
  396.                                        BackAndSideDampen * Vector3.back);
  397.  
  398.             if (primaryAxis.x < 0.0f)
  399.                 MoveThrottle += ort * (Mathf.Abs(primaryAxis.x) * transform.lossyScale.x * moveInfluence *
  400.                                        BackAndSideDampen * Vector3.left);
  401.  
  402.             if (primaryAxis.x > 0.0f)
  403.                 MoveThrottle += ort * (primaryAxis.x * transform.lossyScale.x * moveInfluence * BackAndSideDampen *
  404.                                        Vector3.right);
  405.  
  406.             if (secondaryAxis.y < 0.0f)
  407.                 MoveThrottle += ort * (Mathf.Abs(primaryAxis.y) * transform.lossyScale.y * moveInfluence *
  408.                                        BackAndSideDampen * Vector3.down);
  409.  
  410.             if (secondaryAxis.y > 0.0f)
  411.                 MoveThrottle += ort * (primaryAxis.y * transform.lossyScale.y * moveInfluence * BackAndSideDampen *
  412.                                        Vector3.up);
  413.         }
  414.  
  415.         if (EnableRotation)
  416.         {
  417.             Vector3 euler = transform.rotation.eulerAngles;
  418.             float rotateInfluence = SimulationRate * Time.deltaTime * RotationAmount * RotationScaleMultiplier;
  419.  
  420.             bool curHatLeft = OVRInput.Get(OVRInput.Button.PrimaryShoulder);
  421.  
  422.             if (curHatLeft && !prevHatLeft)
  423.                 euler.y -= RotationRatchet;
  424.  
  425.             prevHatLeft = curHatLeft;
  426.  
  427.             bool curHatRight = OVRInput.Get(OVRInput.Button.SecondaryShoulder);
  428.  
  429.             if (curHatRight && !prevHatRight)
  430.                 euler.y += RotationRatchet;
  431.  
  432.             prevHatRight = curHatRight;
  433.  
  434.             euler.y += buttonRotation;
  435.             buttonRotation = 0f;
  436.  
  437.  
  438. #if !UNITY_ANDROID || UNITY_EDITOR
  439.             if (!SkipMouseRotation)
  440.                 euler.y += Input.GetAxis("Mouse X") * rotateInfluence * 3.25f;
  441. #endif
  442.  
  443.             if (SnapRotation)
  444.             {
  445.  
  446.                 if (OVRInput.Get(OVRInput.Button.SecondaryThumbstickLeft))
  447.                 {
  448.                     if (ReadyToSnapTurn)
  449.                     {
  450.                         euler.y -= RotationRatchet;
  451.                         ReadyToSnapTurn = false;
  452.                     }
  453.                 }
  454.                 else if (OVRInput.Get(OVRInput.Button.SecondaryThumbstickRight))
  455.                 {
  456.                     if (ReadyToSnapTurn)
  457.                     {
  458.                         euler.y += RotationRatchet;
  459.                         ReadyToSnapTurn = false;
  460.                     }
  461.                 }
  462.                 else
  463.                 {
  464.                     ReadyToSnapTurn = true;
  465.                 }
  466.             }
  467.             else
  468.             {
  469.                 Vector2 secondaryAxis = OVRInput.Get(OVRInput.Axis2D.SecondaryThumbstick);
  470.                 euler.y += secondaryAxis.x * rotateInfluence;
  471.             }
  472.  
  473.             transform.rotation = Quaternion.Euler(euler);
  474.         }
  475.     }
  476.  
  477.  
  478.     /// <summary>
  479.     /// Invoked by OVRCameraRig's UpdatedAnchors callback. Allows the Hmd rotation to update the facing direction of the player.
  480.     /// </summary>
  481.     public void UpdateTransform(OVRCameraRig rig)
  482.     {
  483.         Transform root = CameraRig.trackingSpace;
  484.         Transform centerEye = CameraRig.centerEyeAnchor;
  485.  
  486.         if (HmdRotatesY && !Teleported)
  487.         {
  488.             Vector3 prevPos = root.position;
  489.             Quaternion prevRot = root.rotation;
  490.  
  491.             transform.rotation = Quaternion.Euler(0.0f, centerEye.rotation.eulerAngles.y, 0.0f);
  492.  
  493.             root.position = prevPos;
  494.             root.rotation = prevRot;
  495.         }
  496.  
  497.         UpdateController();
  498.         if (TransformUpdated != null)
  499.         {
  500.             TransformUpdated(root);
  501.         }
  502.     }
  503.  
  504.     /// <summary>
  505.     /// Jump! Must be enabled manually.
  506.     /// </summary>
  507.     public bool Jump()
  508.     {
  509.  
  510.         /*
  511.         if (!Controller.isGrounded)
  512.             return false;
  513.  
  514.         MoveThrottle += new Vector3(0, transform.lossyScale.y * JumpForce, 0);
  515.         */
  516.         return true;
  517.  
  518.    
  519.     }
  520.  
  521.     /// <summary>
  522.     /// Stop this instance.
  523.     /// </summary>
  524.     public void Stop()
  525.     {
  526.         Controller.Move(Vector3.zero);
  527.         MoveThrottle = Vector3.zero;
  528.         FallSpeed = 0.0f;
  529.     }
  530.  
  531.     /// <summary>
  532.     /// Gets the move scale multiplier.
  533.     /// </summary>
  534.     /// <param name="moveScaleMultiplier">Move scale multiplier.</param>
  535.     public void GetMoveScaleMultiplier(ref float moveScaleMultiplier)
  536.     {
  537.         moveScaleMultiplier = MoveScaleMultiplier;
  538.     }
  539.  
  540.     /// <summary>
  541.     /// Sets the move scale multiplier.
  542.     /// </summary>
  543.     /// <param name="moveScaleMultiplier">Move scale multiplier.</param>
  544.     public void SetMoveScaleMultiplier(float moveScaleMultiplier)
  545.     {
  546.         MoveScaleMultiplier = moveScaleMultiplier;
  547.     }
  548.  
  549.     /// <summary>
  550.     /// Gets the rotation scale multiplier.
  551.     /// </summary>
  552.     /// <param name="rotationScaleMultiplier">Rotation scale multiplier.</param>
  553.     public void GetRotationScaleMultiplier(ref float rotationScaleMultiplier)
  554.     {
  555.         rotationScaleMultiplier = RotationScaleMultiplier;
  556.     }
  557.  
  558.     /// <summary>
  559.     /// Sets the rotation scale multiplier.
  560.     /// </summary>
  561.     /// <param name="rotationScaleMultiplier">Rotation scale multiplier.</param>
  562.     public void SetRotationScaleMultiplier(float rotationScaleMultiplier)
  563.     {
  564.         RotationScaleMultiplier = rotationScaleMultiplier;
  565.     }
  566.  
  567.     /// <summary>
  568.     /// Gets the allow mouse rotation.
  569.     /// </summary>
  570.     /// <param name="skipMouseRotation">Allow mouse rotation.</param>
  571.     public void GetSkipMouseRotation(ref bool skipMouseRotation)
  572.     {
  573.         skipMouseRotation = SkipMouseRotation;
  574.     }
  575.  
  576.     /// <summary>
  577.     /// Sets the allow mouse rotation.
  578.     /// </summary>
  579.     /// <param name="skipMouseRotation">If set to <c>true</c> allow mouse rotation.</param>
  580.     public void SetSkipMouseRotation(bool skipMouseRotation)
  581.     {
  582.         SkipMouseRotation = skipMouseRotation;
  583.     }
  584.  
  585.     /// <summary>
  586.     /// Gets the halt update movement.
  587.     /// </summary>
  588.     /// <param name="haltUpdateMovement">Halt update movement.</param>
  589.     public void GetHaltUpdateMovement(ref bool haltUpdateMovement)
  590.     {
  591.         haltUpdateMovement = HaltUpdateMovement;
  592.     }
  593.  
  594.     /// <summary>
  595.     /// Sets the halt update movement.
  596.     /// </summary>
  597.     /// <param name="haltUpdateMovement">If set to <c>true</c> halt update movement.</param>
  598.     public void SetHaltUpdateMovement(bool haltUpdateMovement)
  599.     {
  600.         HaltUpdateMovement = haltUpdateMovement;
  601.     }
  602.  
  603.     /// <summary>
  604.     /// Resets the player look rotation when the device orientation is reset.
  605.     /// </summary>
  606.     public void ResetOrientation()
  607.     {
  608.         if (HmdResetsY && !HmdRotatesY)
  609.         {
  610.             Vector3 euler = transform.rotation.eulerAngles;
  611.             euler.y = InitialYRotation;
  612.             transform.rotation = Quaternion.Euler(euler);
  613.         }
  614.     }
  615. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement