I've implemented a top-down car movement based on arrows that works OK, but I'm unsatisfied because the drift doesn't form a big enough circle.
The car has one of 8 directions: west (left), east (right), north (up), south (down), northwest (up-left), northeast (up-right), southwest (down-left) and southeast (down-right).
That's the code I've for acceleration:
var accel_force: Vector2:
get:
if accel_dir == null:
return Vector2.ZERO
var from_rad := deg_to_rad(self.rotation_degrees)
return Vector2(-sin(from_rad), cos(from_rad)) * ACCEL_FORCE
- ... at
_process
self.apply_central_force(self.accel_force)
One example of how it works: if you're pointing towards south and keep accelerating north, you'll drift until you're pointing to north, so the force vector isn't simply (0, -1).
To clarify, the south (down) direction is 0° degrees. The issue I'm having is that the drift has a shorter radius than I wanted.