Exemplo n.º 1
0
    private void Awake()
    {
        // checks if script exists or creates it
        if (_instance != null && _instance != this)
        {
            Destroy(this.gameObject);
        }
        else
        {
            _instance = this;
        }

        inputActions = new InputActionManager();
    }
Exemplo n.º 2
0
    public void Awake()
    {
        m_ActionManager = new InputActionManager();

        ////TODO: this currently falls over due to missing support for composites in InputActionManager
        ////TEMP: we don't yet have support for setting up composite bindings in the UI; hack
        ////      in WASD keybindings as a temp workaround
        controls.gameplay.move.AppendCompositeBinding("Dpad")
        .With("Left", "<Keyboard>/a")
        .With("Right", "<Keyboard>/d")
        .With("Up", "<Keyboard>/w")
        .With("Down", "<Keyboard>/s");

        m_ActionManager.AddActionMap(controls.gameplay);
    }
Exemplo n.º 3
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);
            }
Exemplo n.º 4
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);
            }
Exemplo n.º 5
0
    protected override RollbackInputBaseActions GetCurrentActionsValue(int controllerId)
    {
        if (controllerToPlayers.Count <= controllerId)
        {
            return(new RollbackInputBaseActions());
        }

        InputDevice currentDevice = controllerToPlayers[controllerId].device;

        RollbackInputBaseActions actionsValue = new RollbackInputBaseActions(5);

        SetBitFromAction(InputActionManager.InputType.LEFT, ref actionsValue, currentDevice);
        SetBitFromAction(InputActionManager.InputType.RIGHT, ref actionsValue, currentDevice);
        SetBitFromAction(InputActionManager.InputType.UP, ref actionsValue, currentDevice);
        SetBitFromAction(InputActionManager.InputType.DOWN, ref actionsValue, currentDevice);
        SetBitFromAction(InputActionManager.InputType.SHOOT, ref actionsValue, currentDevice);

        actionsValue.SetHorizontalAxis(InputActionManager.GetAxis(InputActionManager.AxisType.HORIZONTAL, currentDevice));
        actionsValue.SetVerticalAxis(InputActionManager.GetAxis(InputActionManager.AxisType.VERTICAL, currentDevice));

        return(actionsValue);
    }
 private void OnDisable()
 {
     InputActionManager.Release(inputAction.action, InputAction_performed);
 }
 private void OnEnable()
 {
     InputActionManager.Request(inputAction.action, InputAction_performed);
 }
Exemplo n.º 8
0
 void OnRightThumbstickClickActivation()
 {
     HMDSimulator.getCamera.rotation = Quaternion.Euler(Vector3.zero);
     InputActionManager.setRightThumbstickClickActivated(false);
 }
Exemplo n.º 9
0
 void SetBitFromAction(InputActionManager.InputType inputType, ref RollbackInputBaseActions actionsValue, InputDevice inputDevice)
 {
     actionsValue.SetOrClearBit((int)inputType, InputActionManager.GetInput(inputType, inputDevice));
 }