0

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).

How it works

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.

Hydroper
  • 344
  • 2
  • 9
  • 1
    This is what comes to mind: separate rotation form acceleration, so you can specify a turning speed (or even a turning acceleration) which would give you control over that separate from how quickly the car gains speed when going straight. And then try to tweak it. – Theraot Aug 31 '23 at 01:40

0 Answers0