My HexWord puzzle uses hex flowers and hex rings. A flower refers to the center hex and its 6 adjacent hexes, while a hex ring is just the 6 adjacent hexes without the center hex.
Anyway, I wanted a physically tactile feel to spinning the ring. Like a combination lock. Sticky at the notch. Free in transit. And magnetic (snaps home) as it locks.
#ilovemath #gamedev #indiedev #mathisbeautiful #sinwave #reactnative #puzzlegame #hexword
The solution turned out to be #math and #sin.
A full spin of the ring is 360 degrees, 2π, or 6.28 radians. Essentially, the number of degrees measured in radians.
So the formula would become: stickiness = ring_spin - 0.08 * sin(ring_spin * 6)
We get a sine wave per hex position (ring_spin * 6), so the sine wave rises and falls for each hex. If we did not multiply by six, the sine wave would affect one entire rotation.
Here, 0.08 is the detent strength, or how quickly it snaps into place. This is a tunable variable to get the right feel.
So as sin rises to +1, stickiness lags ring_spin and it feels sticky. As sin returns to 0, the ring spins freely. As sin falls to -1, stickiness lags ring_spin and it snaps home.
https://hexword.mubergapps.com
#ilovemath #gamedev #indiedev #mathisbeautiful #sinwave #reactnative #puzzlegame #hexword