https://github.com/mahdirahmatii/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.
https://github.com/mahdirahmatii/unity-easy-haptic-manager
android feedback gamefeel haptic-feedback haptics mobile-development mobile-game unity unity-android unity-csharp unity-native-plugin unity-plugin vibration vibration-effect
Last synced: 3 months ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/mahdirahmatii/unity-easy-haptic-manager
- Owner: MahdiRahmatii
- License: mit
- Created: 2025-10-31T17:14:29.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-11-01T14:31:56.000Z (3 months ago)
- Last Synced: 2025-11-01T15:14:42.110Z (3 months ago)
- Topics: android, feedback, gamefeel, haptic-feedback, haptics, mobile-development, mobile-game, unity, unity-android, unity-csharp, unity-native-plugin, unity-plugin, vibration, vibration-effect
- Language: C#
- Homepage:
- Size: 12.7 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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/..)
```xml
```
4. 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! 🙏