Esempio n. 1
0
        static IEnumerator VibrateControllerCoroutine(Gamepad pad, VibrationSettings settings)
        {
            pad.SetMotorSpeeds(settings.vibrationIntensity, settings.vibrationIntensity);
            yield return(new WaitForSeconds(settings.vibrationDuration));

            pad.SetMotorSpeeds(0f, 0f);
        }
Esempio n. 2
0
        /// <summary>
        /// Vibrates the current controller, if it exists
        /// </summary>
        /// <param name="settings">The settings of the vibration</param>
        public static void VibrateController(VibrationSettings settings)
        {
            Gamepad pad = Gamepad.current;

            if (pad == null)
            {
                return;
            }

            WSoft.Core.GameManager gameManager = WSoft.Core.GameManager.Instance;
            if (gameManager == null)
            {
                Debug.LogError("Game Manager does not exist in current scene");
                return;
            }
            gameManager.StartCoroutine(VibrateControllerCoroutine(pad, settings));
        }
Esempio n. 3
0
        /// <summary>
        /// Vibrates the controller at the specified index, if it exists
        /// </summary>
        /// <param name="index">The index to vibrate the controller</param>
        /// <param name="settings">The settings of the vibration</param>
        public static void VibrateController(int index, VibrationSettings settings)
        {
            UnityEngine.InputSystem.Utilities.ReadOnlyArray <Gamepad> pads = Gamepad.all;
            if (index >= pads.Count)
            {
                Debug.LogError("Controller at index " + index + " not found.");
                return;
            }
            Gamepad currentGamepad = pads[index];

            WSoft.Core.GameManager gameManager = WSoft.Core.GameManager.Instance;
            if (gameManager == null)
            {
                Debug.LogError("Game Manager does not exist in current scene");
                return;
            }
            gameManager.StartCoroutine(VibrateControllerCoroutine(currentGamepad, settings));
        }