← all posts site ↗

the hoverboard that balances on four corner springs

started with the smallest possible snippet, applying a force at a point on a rigidbody in unity, the impulse that spins an object and knocks it away from where it was hit. then the hoverboard question came up and it turned into the better way to think about it. no full scripts, just the approach, which is what i wanted anyway.

each thruster is a spring. a spring pushes harder the closer that corner gets to the ground, so four corners means the board levels itself, a low corner gets more push and comes back up. two lines do the work per corner. the spring push is hooke's law, rest height minus hit distance times stiffness, and the damping is negative vertical velocity times a factor, which kills the bounce. apply both together at the corner point with add force at position.

that call is the key trick. a force at an off center point produces torque, so that corner pitches the board, and with four of them fighting each other the board just balances. a raycast from each corner straight down measures the hit distance that feeds the spring. tuning: stiffness, high is snappy and low is saggy. damping, high is no bounce but floaty and low boings forever. rest height decides where it wants to sit.

two traps. physics queries on a rigidbody need to run in fixed update, not update, or the spring jitters. and debug drawing makes it visible, draw the aim line green when a corner is grounded and red when it's in the air, so you watch the balance instead of guessing.