BatchSetup vs Script
There are two main ways to integrate Hapbeat haptics in Unity:
- BatchSetup / Inspector components — connect directly to UnityEvents, Animator states, or Collision callbacks
- Call
HapbeatBridge/HapbeatManagerfrom a script — fire haptics actively from your own logic
Both are valid; choose based on the situation.
Quick Reference
Section titled “Quick Reference”| Situation | Recommended approach |
|---|---|
| Applying the same Trigger to 3 or more objects | BatchSetup |
| Fire condition is simply “collision occurred / slider moved / state changed” | Component |
| Gain is either the EventMap entry default or velocity scaling alone | Component |
| Fire condition depends on multiple game states (charge level, item count, HP, etc.) | Script |
| Gain / pan / target need to be computed at runtime | Script |
| One fire point needs to branch into multiple Events | Script |
| The same event fires from many places (e.g. logic centralised in a custom Bridge) | Script |
To see which approach each Showcase zone uses, refer to the Wiring Reference. The “Input type → Reference Zone” matrix is on the same page.
Design Tips
Section titled “Design Tips”Create a Bridge subclass
Section titled “Create a Bridge subclass”Even when scripting, calling HapbeatManager.Instance.Play() directly everywhere is not recommended. Instead, create one project-specific HapbeatBridge subclass and centralise all fire logic there.
Why:
- Gain / target / curve tuning stays in one place
- Haptic logic is decoupled from game logic, making it easier to maintain
- Showcase’s
ShowcaseBridgefollows this pattern (Scripts/ShowcaseBridge.cs)
Combine both approaches
Section titled “Combine both approaches”Z3 Fishing is a typical example of combining both:
HapbeatSequenceTrigger(component) declares the Fire→Loop→Stop structureFishingController(script) callsSequence.Fire()/Stop()in response to mouse inputHapbeatParameterBinding(component) maps the object’s motion to gain during the loop
“Use components for the parts you can express declaratively; use script only where logic is required” makes for readable, maintainable code.
Summary
Section titled “Summary”- First ask whether EventMap Window can express what you need
- If not, use a custom Bridge subclass + script
- Mixing both approaches in the same scene is fine (Showcase does exactly this)
- For concrete examples, see the “Per-Zone Wiring Details” section in the Wiring Reference