Skip to main content

Gesture throws

Enable with:

motion.setMode(.gesture)

State machine​

IDLE
→ pull back (relY drops / velocity negative)
→ ARMED (gesturePrimed == true)
→ thrust forward
→ THROW (shotTriggered, throwPower > 0)
→ cooldown (gestureCooldown)

GestureDetector uses relative vertical motion (relY) and per-frame velocity, scaled to 60 fps via frameScale.

Game code​

if input.gesturePrimed {
hud.show("Pull back…")
}

if input.shotTriggered {
game.throw(power: input.throwPower)
}

In .gesture and .pointer modes, input.primaryAction is also true on the throw frame (click OR throw OR velocity action). In .paddle mode, primaryAction is the BLE button only — see GameInput.

Tuning​

MotionConfig fieldEffect
gesturePullbackDeltaHow far back before armed
gesturePullSpeedFast pull sensitivity
gestureMinThrustSpeedForward speed to fire
gestureMinRelYMinimum forward displacement
gestureThresholdLegacy scale gate
gestureCooldownMinimum time between throws

Preset defaults are in MotionConfig.preset(for: .gesture).

Bowling vs Dart​

Both use .gesture. Bowling maps throwPower to SceneKit impulse; Dart uses it for launch speed. Input profile is set in GameManager / BowlingInputHandler / DartThrowController in the sample app.

Configuration · GameInput