# MOST Haptic Feedback

Quick and simple MOST, but it's essential for all mobile games...

<figure><img src="/files/1meQzNNKzweuxfONPcr8" alt="" width="375"><figcaption><p>Haptic Feedback Demo scene</p></figcaption></figure>

## <mark style="color:yellow;">Key Features</mark> 🔥

* Works on iOS (10+ / iPhone 7 or above) and Android (5.0+)
* Automatically adapts to device capabilities
* No dependencies required
* iOS: All HapticFeedback from IOS UIKit + Custom Haptic Pattern generator
* Android: Custom vibration patterns generator with amplitude control
* Regular Vibrate: fallbacks for unsupported devices
* GetHapticStatus() to check device support
* Editor-safe (no errors in Play Mode)
* One-line setup: \`HapticManager.Generate(HapticTypes.Success);\`
* No manual Xcode/AndroidManifest edits required
* Includes ready-to-use prefabs and example scripts
* Toggle haptics globally with \`HapticManager.HapticsEnabled\`
* Auto-fallback for unsupported devices

## <mark style="color:red;">Enable and Disable</mark> Haptic feedback globally

```csharp
// Enable or disable haptic feedback globally // Saved in-game data
Most_HapticFeedback.HapticsEnabled return or set bool
```

## <mark style="color:red;">Generate</mark> Basic haptic feedback

<pre class="language-csharp"><code class="lang-csharp">// generate a haptic feedback from the built-in(API) haptics
Most_HapticFeedback.Generate(Most_HapticFeedback.HapticTypes);

// generate a haptic feedback from the built-in(API) haptics and set a cooldown after
// Haptic With Cooldown is very useful for continuous haptic spamming
// for example... Sliders, Scrolling, continuous damage...
Most_HapticFeedback.GenerateWithCooldown(Most_HapticFeedback.HapticTypes, cooldown);

<strong>// ___________ All Baisc Haptics from iOS UIToolKit ___________ //
</strong><strong>
</strong>// These names from iOS UIToolKit // call it default haptics
Selection    // case 0 // IOS 10+
Success      // case 1 // IOS 10+
Warning      // case 2 // IOS 10+
Failure      // case 3 // IOS 10+
LightImpact  // case 4 // IOS 10+
MediumImpact // case 5 // IOS 10+
HeavyImpact  // case 6 // IOS 10+
RigidImpact  // case 7 // IOS 13+ &#x3C;&#x3C;
SoftImpact   // case 8 // IOS 13+ &#x3C;&#x3C;

// I used these names to make a default haptics for Android as well
// you will find IOSDefaultHapticsToAndroidPatterns() function inside MOST_HapticFeedback
// and edit these values if you want
</code></pre>

## <mark style="color:red;">Examples:</mark> Basic haptic feedback

```csharp
// To call haptic type
Most_HapticFeedback.HapticTypes.Type;

// example // define a selection haptic
Most_HapticFeedback.HapticTypes.Selection;

// example // haptic feedback as a public property
public Most_HapticFeedback.HapticTypes BasicHaptic;

// example // for activating a haptic feedback
Most_HapticFeedback.Generate(Most_HapticFeedback.HapticTypes.Selection);

// example // for activating a haptic feedback using public property
Most_HapticFeedback.Generate(BasicHaptic); 

// example // for activating a haptic feedback with cooldown using public property
Most_HapticFeedback.GenerateWithCooldown(BasicHaptic, 0.1f);
```

## <mark style="color:red;">Custom Haptic Pattern</mark>

```csharp
// define a custom haptic as a public property
public Most_HapticFeedback.CustomHapticPattern CustomHapticPattern;
```

<figure><img src="/files/K5DImRYAtDq7aSOWKQmw" alt=""><figcaption><p>Custom haptic pattern as public property</p></figcaption></figure>

<mark style="color:blue;">**iOS Haptic Pattern**</mark>

* <mark style="color:yellow;">**Delay:**</mark> the delay before starting this pulse  <mark style="color:red;">in milliseconds</mark>
* <mark style="color:yellow;">**Pulse Type:**</mark> Haptic type of this pulse

<mark style="color:blue;">**Android Haptic Pattern**</mark>

* <mark style="color:yellow;">**Delay:**</mark> the delay before starting this pulse  <mark style="color:red;">in milliseconds</mark>
* <mark style="color:yellow;">**Pulse Time:**</mark> Pulse time  <mark style="color:red;">in milliseconds</mark>
* <mark style="color:yellow;">**Pulse Strength:**</mark> vibration strength of the pulse  <mark style="color:red;">integer (0-255)</mark>

<mark style="color:yellow;">**After creating the haptic pattern for Android and iOS you can now test it on a real device.**</mark>

```csharp
// Call a custom haptic pattern // This function is only for the custom haptic patterns
StartCoroutine(Most_HapticFeedback.GeneratePattern(CustomHapticPattern));
// has to be a Coroutine function to apply the delay
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://solo-player.gitbook.io/most-in-one/most-systems/most-haptic-feedback.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
