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)
}

input.primaryAction is also true on the throw frame (click OR throw).

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