Skip to content

Instantly share code, notes, and snippets.

@irfanbaysal
Created January 10, 2023 13:34
Show Gist options
  • Save irfanbaysal/7e771ea255cb6d9758624281ef38a27a to your computer and use it in GitHub Desktop.
Save irfanbaysal/7e771ea255cb6d9758624281ef38a27a to your computer and use it in GitHub Desktop.
Haptic Methods
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