/Unity-Easy-Haptic-Manager

A lightweight, dependency-free Unity plugin that delivers consistent, customizable haptic feedback on all Android devices. It bridges Unity C# with Android’s native VibrationEffect and VibratorManager APIs for precise, reliable control over vibration strength and duration.

Primary LanguageC#MIT LicenseMIT

Unity Easy Haptic Manager (Android)

A lightweight and consistent Haptic feedback plugin for Unity (Android).
It gives you precise vibration control across all Android devices — from older phones to the latest Android 14+ models.


🚀 Features

  • ✅ Simple API — just one line to trigger vibration.
  • ✅ Works on all Android devices (API 21+)
  • ✅ Uses VibratorManager automatically on Android 12+ (multi-motor support)
  • ✅ Supports custom vibration duration and amplitude
  • ✅ Provides 5 adjustable haptic levels — from subtle taps to strong impacts
  • ✅ Safe fallback (Handheld.Vibrate) in Editor or non-Android builds

📦 Installation

  1. Clone or download this repository.
  2. Copy the folders into your Unity project.
  3. Ensure your Android Manifest includes: (This is already included if you use the provided manifest in /Plugins/Android/..)
<uses-permission android:name="android.permission.VIBRATE" />
  1. Build your project for Android. That’s it — no Gradle or Java configuration needed.

🧠 Usage

1️⃣ Initialize (required once)

Call this early, like in your game’s startup scene:

void Start() => HapticManager.Initialize();

2️⃣ Simple Vibrate: predefined haptic levels

1. HapticManager.SimpleVibrate(HapticLevel.VeryLight);
2. HapticManager.SimpleVibrate(HapticLevel.Light);
3. HapticManager.SimpleVibrate(HapticLevel.Medium);
4. HapticManager.SimpleVibrate(HapticLevel.Heavy);
5. HapticManager.SimpleVibrate(HapticLevel.Extreme);

3️⃣ Custom Vibrate: define your own vibration

HapticManager.CustomVibrate(duration: 80, amplitude: 200); // Duration (ms), Amplitude (1–255)

4️⃣ Stop ongoing vibration

HapticManager.Stop();

🎛️ Simple Haptic Levels

Level Name Duration (ms) Amplitude
1 VeryLight 15 40
2 Light 25 80
3 Medium 40 150
4 Heavy 70 220
5 Extreme 100 255

🎮 Demo Scene

A sample scene is included at:

Assets\Plugins\Android\HapticPlugin\Demo\...

It provides UI buttons to test each Haptic Level and verify everything is working properly on your Android device.


⭐ If this plugin helps your project, consider giving it a star on GitHub! 🙏