Can get attack rumble while sucking?
This commit is contained in:
parent
5ed2045b30
commit
f4ee5d0de1
@ -1,14 +1,14 @@
|
||||
#nullable enable
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Cinemachine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
public class ScreenShaker : MonoBehaviour {
|
||||
CinemachineVirtualCamera cam;
|
||||
CinemachineBasicMultiChannelPerlin noise;
|
||||
Coroutine coroutine;
|
||||
bool rumbleHeld;
|
||||
CinemachineVirtualCamera cam = null!;
|
||||
CinemachineBasicMultiChannelPerlin noise = null!;
|
||||
Coroutine? coroutine;
|
||||
(float, float)? heldRumble;
|
||||
|
||||
void Awake() {
|
||||
cam = GetComponent<CinemachineVirtualCamera>();
|
||||
@ -23,26 +23,27 @@ public class ScreenShaker : MonoBehaviour {
|
||||
}
|
||||
|
||||
public void StartHeldRumble(float rumbleLowFreq = 0.25f, float rumbleHighFreq = 0.75f) {
|
||||
rumbleHeld = true;
|
||||
heldRumble = (rumbleLowFreq, rumbleHighFreq);
|
||||
Gamepad.current.SetMotorSpeeds(rumbleLowFreq, rumbleHighFreq);
|
||||
}
|
||||
|
||||
public void StopHeldRumble() {
|
||||
rumbleHeld = false;
|
||||
heldRumble = null;
|
||||
Gamepad.current.ResetHaptics();
|
||||
}
|
||||
|
||||
IEnumerator ShakeCoroutine(float magnitude, float rumbleLowFreq, float rumbleHighFreq, float duration) {
|
||||
noise.m_AmplitudeGain = magnitude;
|
||||
noise.m_FrequencyGain = 10f;
|
||||
Gamepad.current.SetMotorSpeeds(rumbleLowFreq, rumbleHighFreq);
|
||||
Gamepad.current.SetMotorSpeeds(rumbleLowFreq, rumbleHighFreq);
|
||||
|
||||
yield return new WaitForSecondsRealtime(duration);
|
||||
|
||||
noise.m_AmplitudeGain = 0f;
|
||||
noise.m_FrequencyGain = 1f;
|
||||
if (!rumbleHeld)
|
||||
Gamepad.current.ResetHaptics();
|
||||
if (heldRumble != null)
|
||||
Gamepad.current.SetMotorSpeeds(heldRumble.Value.Item1, heldRumble.Value.Item2);
|
||||
else
|
||||
Gamepad.current.ResetHaptics();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user