How Play FORE reads a golf swing at 100Hz with CoreMotion
Play FORE is a solo indie iOS golf game where the iPhone is the club. You hold it like a short iron, soft-swing on a haptic GO, and CoreMotion turns that motion into a shot at one island green (~153 yd).
There is no aim stick and no power meter to drag. The swing is the control scheme. This post is the engineering story: sampling CMDeviceMotion, mapping speed and face, rejecting junk motion, and capping hard swings so living-room play stays safe.
Sampling CMDeviceMotion at ~100Hz
On every swing attempt, Play FORE listens to the gyroscope and accelerometer through CoreMotion. The useful stream is device motion at roughly 100Hz—fast enough to catch the short window of a soft one-handed swing without pretending we have a launch-monitor bay.
What we care about in that stream is not a continuous replay of the golf swing. It is two derived signals:
- Peak angular velocity in the swing window → how hard you swung → carry
- Device roll around impact → how open or closed the “face” was → fade / draw
Speed answers “how far.” Face answers “left or right of the line.” Soft swings, held securely, are the design surface. Full-speed living-room drivers are not.
Soft-swing calibration (and why hard swings are capped)
The product brief is living-room golf. Soft swings only. That is a safety and sensing constraint.
Hard swings fail for two reasons:
- Safety. Phones slip. Furniture and wrists exist. Soft tempo is the only tempo we want people practicing indoors.
- Signal quality. A wild thrash saturates the useful part of the motion window and turns club speed into noise. Soft swings keep peak angular velocity in a range we can map to a stock short-iron carry.
Calibration sits in that soft band. Overswing is capped—you are not rewarded for whipping the phone like a driver. The teaching range reinforces it: the soft/short drill fails if you swing too hard. Tempo is part of the mechanic.
Speed → carry, roll → face
Once a swing is accepted:
- Speed → carry. Peak angular velocity maps to power and distance—short-iron numbers around the ~153 yd island target, not Tour driver math.
- Face / wrist roll → draw / fade. Roll at impact is face angle: closed pulls into a draw/hook shape; open pushes into a fade/slice shape.
Players feel this immediately when water surrounds the green. Miss left or right and you learn whether the face was closed or open.
False positives: pocket bumps and accidental motion
The hard part of motion games is not reading a swing. It is deciding which motion was the swing.
Phones live in pockets and restless hands. Bumps, sit-downs, and grip adjusts all look like acceleration if thresholds are naïve. Play FORE gates the window: hold still, countdown with haptic GO, then a short capture where we look for a coherent soft swing—not every jolt the IMU saw that minute.
False positives still happen. Pocket bumps and half-swings are the classics. The fix is product-shaped as much as filter-shaped: clear GO timing, soft-swing expectations, and drills that teach what “counts.” When detection fails, we would rather ask for another swing than invent a shot from noise.
Teaching range: six drills that expose the sensors
Before free play, a short teaching range walks through what the sensors reward:
- Any swing — on-rails easy; learn GO → soft swing
- Soft / short — fail if too hard
- Hard / long — stretch distance without leaving soft-swing safety
- Closed face — pull left; feel roll → draw
- Open face — push right; feel roll → fade
- Draw into left-to-right wind — finish near the pin; combine speed, face, and conditions
Drill 6 is where the pieces meet. That is the same loop free play asks for on the island.
One hole on purpose
The course is deliberately small: one polished par-3 island green over water. Distance control and face awareness matter more when water surrounds the target. The goal was never an 18-hole tour sim. It was swing feel—tempo, carry, and face—on a device you already carry, where a soft swing is the only responsible swing.
If you ship motion input: constrain the gesture, sample fast enough to see the peak, map two axes players can feel, reject junk aggressively, and cap the unsafe end of the range. CoreMotion at ~100Hz is plenty when the gesture is honest.
Play FORE (App Store): https://apps.apple.com/app/id6802967255
Site: https://playfore.app/?utm_source=iosdevweekly
Solo indie by Richard Deetlefs.
Top comments (0)