Skip to content
EN

BatchSetup vs Script

There are two main ways to integrate Hapbeat haptics in Unity:

  1. BatchSetup / Inspector components — connect directly to UnityEvents, Animator states, or Collision callbacks
  2. Call HapbeatBridge / HapbeatManager from a script — fire haptics actively from your own logic

Both are valid; choose based on the situation.

SituationRecommended approach
Applying the same Trigger to 3 or more objectsBatchSetup
Fire condition is simply “collision occurred / slider moved / state changed”Component
Gain is either the EventMap entry default or velocity scaling aloneComponent
Fire condition depends on multiple game states (charge level, item count, HP, etc.)Script
Gain / pan / target need to be computed at runtimeScript
One fire point needs to branch into multiple EventsScript
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.

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 ShowcaseBridge follows this pattern (Scripts/ShowcaseBridge.cs)

Z3 Fishing is a typical example of combining both:

  • HapbeatSequenceTrigger (component) declares the Fire→Loop→Stop structure
  • FishingController (script) calls Sequence.Fire() / Stop() in response to mouse input
  • HapbeatParameterBinding (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.

  • 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