using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.InputSystem; public class RumbleManager : MonoBehaviour { private Gamepad pad; private Coroutine stopRumbleAfterTimeCorutine; public void RumblePulse(float lowFrequency, float highFrequency, float duration, int player) { pad = Gamepad.all[player]; if (pad != null) { pad.SetMotorSpeeds(lowFrequency, highFrequency); stopRumbleAfterTimeCorutine = StartCoroutine(stopRumble(duration, pad)); } } private IEnumerator stopRumble(float duration, Gamepad pad) { float elapsedTime = 0f; while (elapsedTime < duration) { elapsedTime += Time.deltaTime; yield return null; } pad.SetMotorSpeeds(0f, 0f); } }