コード例 #1
0
            void OnXAxisMovementStart(InputAction inputAction)
            {
                float       moveScale = 1.0f;
                float       moveInfluence;
                InputAction zAxisMovement = InputActionManager.getInputAction("zAxisMovement");

                Quaternion originalRotation = HMDSimulator.getCamera.transform.rotation;
                Vector3    originalEuler    = originalRotation.eulerAngles;

                originalEuler.z  = originalEuler.x = 0f;
                originalRotation = Quaternion.Euler(originalEuler);

                if (zAxisMovement.isZAxisAtRest == false)
                {
                    moveScale *= 0.7072f;
                }

                moveScale    *= movementRate * Time.deltaTime;
                moveInfluence = accelerationRate * moveScale;

                if (isRunActive)
                {
                    moveInfluence *= 2.0f;
                }


                if (inputAction.xAxisValue > 0 || inputAction.buttonValue > 0)
                {
                    Debug.LogWarning("xAxisValue: " + inputAction.xAxisValue);
                    Debug.LogWarning("buttonValue: " + inputAction.buttonValue);
                    moveThrottle += originalRotation * (HMDSimulator.getCamera.root.lossyScale.x * moveInfluence * backAndSideDampingRate * Vector3.right);
                    moveThrottle += originalRotation * (Mathf.Max(inputAction.buttonValue, inputAction.xAxisValue) * HMDSimulator.getCamera.lossyScale.x * moveInfluence * backAndSideDampingRate * Vector3.right);
                    Debug.LogWarning("moveThrottle: " + moveThrottle.ToString());
                }
                if (inputAction.xAxisValue < 0 || inputAction.buttonValue < 0)
                {
                    moveThrottle += originalRotation * (HMDSimulator.getCamera.root.lossyScale.x * moveInfluence * backAndSideDampingRate * Vector3.left);
                    moveThrottle += originalRotation * (Mathf.Max(Mathf.Abs(inputAction.buttonValue), Mathf.Abs(inputAction.xAxisValue)) * HMDSimulator.getCamera.lossyScale.x * moveInfluence * backAndSideDampingRate * Vector3.left);
                }

                moveAvatar(inputAction);
                EventManager.endXAxisMovement(inputAction);
            }
コード例 #2
0
            void OnZAxisMovementStart(InputAction inputAction)
            {
                float       moveScale = 1.0f;
                float       moveInfluence;
                InputAction xAxisMovement = InputActionManager.getInputAction("xAxisMovement");

                Quaternion originalRotation = HMDSimulator.getCamera.transform.rotation;
                Vector3    originalEuler    = originalRotation.eulerAngles;

                originalEuler.z  = originalEuler.x = 0f;
                originalRotation = Quaternion.Euler(originalEuler);

                if (xAxisMovement.isXAxisAtRest == false)
                {
                    moveScale *= 0.7072f;
                }

                moveScale    *= movementRate * Time.deltaTime;
                moveInfluence = accelerationRate * moveScale;

                if (isRunActive)
                {
                    moveInfluence *= 2.0f;
                }

                if (inputAction.zAxisValue > 0 || inputAction.buttonValue > 0)
                {
                    moveThrottle += originalRotation * (HMDSimulator.getCamera.lossyScale.z * moveInfluence * forwardDampingRate * Vector3.forward);
                    moveThrottle += originalRotation * (Mathf.Max(inputAction.buttonValue, inputAction.zAxisValue) * HMDSimulator.getCamera.lossyScale.z * moveInfluence * forwardDampingRate * Vector3.forward);
                }
                if (inputAction.zAxisValue < 0 || inputAction.buttonValue < 0)
                {
                    moveThrottle += originalRotation * (HMDSimulator.getCamera.lossyScale.z * moveInfluence * backAndSideDampingRate * Vector3.back);
                    moveThrottle += originalRotation * (Mathf.Max(Mathf.Abs(inputAction.buttonValue), Mathf.Abs(inputAction.zAxisValue)) * HMDSimulator.getCamera.lossyScale.z * moveInfluence * backAndSideDampingRate * Vector3.back);
                }

                moveAvatar(inputAction);
                EventManager.endZAxisMovement(inputAction);
            }