Created
January 10, 2023 13:34
-
-
Save irfanbaysal/7e771ea255cb6d9758624281ef38a27a to your computer and use it in GitHub Desktop.
Haptic Methods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected float hapticTime; | |
protected virtual void ContinuousHaptic(float limit, HapticPatterns.PresetType presetType = HapticPatterns.PresetType.LightImpact) | |
{ | |
hapticTime += Time.deltaTime; | |
hapticTime = Mathf.Clamp(hapticTime, 0, limit); | |
if (!Mathf.Approximately(hapticTime, limit)) | |
{ | |
return; | |
} | |
PlayHaptic(HapticPatterns.PresetType.LightImpact); | |
hapticTime = 0f; | |
} | |
protected virtual void ContinuousChangeableHaptic(float limit,float amount) | |
{ | |
hapticTime += Time.deltaTime; | |
hapticTime = Mathf.Clamp(hapticTime, 0, limit); | |
if (!Mathf.Approximately(hapticTime, limit)) | |
{ | |
return; | |
} | |
HapticPatterns.PlayEmphasis(amount,1f); | |
hapticTime = 0f; | |
} | |
public void PlayHaptic(HapticPatterns.PresetType presetType) | |
{ | |
HapticPatterns.PlayPreset(presetType); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment