Back to all news
Updates

Karting: powerslides, engine sound and a circuit of its own

The kart received physics with tyre slip angles, a handbrake, nitro and a synthesised engine sound. A whole circuit was laid around the karting zone.
A player at the wheel of a kart, seen from the side

Karting has appeared in the game: a kart with powerslides, nitro and a circuit of its own. This is no longer just a turn on wheels but a machine that has to be learned.

Physics instead of a simple turn

The old kinematic model, in which pressing left simply turned the kart, was replaced by a dynamic model with tyre slip angles. It provides understeer at speed, steering that responds to pace, and a handbrake implemented as a softening of the rear tyres: the rear axle breaks loose, and the kart goes sideways exactly as much as it was put there.

A kart in a powerslide on the circuit

The kart itself became 1.75 times longer, the wheels rotate by physics rather than by animation, and Shift engages nitro with a speed ceiling and a gradual bleed. The engine has to be started before the first drive. Collisions between karts are also calculated from their bounding boxes, so leaning on a rival through a corner is possible while driving through them is not.

The sound of the engine and the tyres

There are no recordings of a real engine yet, so the sound is synthesised in Web Audio. The tyres turned out to be the hardest part: white noise read as wind rather than as rubber. A tyre is therefore reproduced as a tone at the tread frequency through resonators that track the speed, with a catch on entry into a slide, a stutter at the limit of grip and a decay after release. The engine ducks underneath the squeal of the tyres.

The nastiest bug of this part was fixed along the way: the game froze completely when the handbrake and nitro were used at the same time. The cause was not in the game’s code but in Web Audio itself, which refused to schedule events inside an already running curve. The engine now schedules no curves at all, and a refusal no longer stops the frame.

The circuit

A whole circuit was laid around the karting zone. It was built from a centreline in the same style that had been measured off a section laid out by hand. For this the map editor learned to place and erase fences with a brush.

The map of the karting circuit with its lakes

A late answer from the server and the kart’s jump

After the circuit was launched a synchronisation bug appeared: precisely at top speed the kart visibly jumped backwards. The server’s answer about the state of the kart always arrives late, by half a round trip plus one tick, and the old reconciliation compared that answer against the prediction of the current moment and read the delay as an error. At nitro speed the difference reached three metres, and at that distance a correction is no longer smoothed but applied as a jump.

A kart at speed on the circuit

The state from the server is now matched against the recent history of the local simulation: a state the kart genuinely passed through is treated as an answer that arrived late, and only the residual after the match is corrected. Measurements show that three seconds of nitro under a 160-millisecond delay leave a residual of less than 20 centimetres and no jumps at all, whereas the old scheme held around three metres.

Also this week

The pitch’s ball no longer leaves the pitch. The perimeter of the football pitch became impassable to balls in both directions: the pitch ball appears on the centre spot and does not leave the field either over the fence or through an open gate, while the balls from the square cannot roll inside. This restriction does not apply to players, stones or hens.

The map editor received tabs instead of a single panel, and objects learned to be picked up and moved: a house lifted by its far corner is placed by that same corner.

Read more