コード例 #1
0
ファイル: PlayerInputHelper.cs プロジェクト: pdxparrot/assets
        public void Rumble(RumbleConfig config)
        {
            if (!InputManager.Instance.EnableVibration || _isRumbling)
            {
                return;
            }

            if (InputManager.Instance.EnableDebug)
            {
                Debug.Log($"Rumbling player input {_playerInput.playerIndex} for {config.Seconds} seconds, (low: {config.LowFrequency} high: {config.HighFrequency})");
            }

            foreach (InputDevice device in _playerInput.devices)
            {
                if (!(device is Gamepad gamepad))
                {
                    continue;
                }

                gamepad.SetMotorSpeeds(config.LowFrequency, config.HighFrequency);
                _isRumbling = true;

                TimeManager.Instance.RunAfterDelay(config.Seconds, () => {
                    gamepad.SetMotorSpeeds(0.0f, 0.0f);
                    _isRumbling = false;
                });
            }
        }
コード例 #2
0
ファイル: GamepadListener.cs プロジェクト: pdxparrot/ggj2019
        public void Rumble(RumbleConfig config)
        {
            if (!InputManager.Instance.EnableVibration || null == Gamepad || _isRumbling)
            {
                return;
            }

            if (InputManager.Instance.DebugInput)
            {
                Debug.Log($"Rumbling gamepad {Gamepad.id} for {config.Seconds} seconds, (low: {config.LowFrequency} high: {config.HighFrequency})");
            }

            Gamepad.SetMotorSpeeds(config.LowFrequency, config.HighFrequency);
            _isRumbling = true;

            TimeManager.Instance.RunAfterDelay(config.Seconds, () => {
                if (null != Gamepad)
                {
                    Gamepad.SetMotorSpeeds(0.0f, 0.0f);
                }
                _isRumbling = false;
            });
        }