πŸ“³Vibration Manager

Used to trigger vibrations (tested on Android / iOS)

Powered by NiceVibrations (FEEL) package

You can call VibrationManager.cs anywere even if it's not replaced in scene.

namespace using Game.Core;

API

public static VibrationsManager Instance;

// This is cooldown between vibrations call, 0.2 seconds by default
// Any vibration call before cooldown elapsed will be ignored
private Cooldown hapticCooldown = new Cooldown(0.2f);

// Is user settings vibro enabled
public bool HapticEnabled;

// Triggers vibration with hapticType pattern
public void DoVibro(HapticPatterns.PresetType hapticType);

Where is already used

VibroBtn.cs that is Button class inheritance, place it on button in UI that will trigger vibro on click.

public class VibroBtn : Button {
    public HapticPatterns.PresetType vibrationType;

    protected override void Start() {
        base.Start();
        onClick.AddListener(() => VibrationsManager.Instance.DoVibro(vibrationType));
    }
}

Example how to use

private void OnPlayerHit() {
    VibrationsManager.Instance.DoVibro(HapticPatterns.PresetType.MediumImpact);
}

Last updated