Here is the code I use for my vehicle:
var maximum_speed_it_can
var speed_kmh
var MAX_ENGINE_FORCE = 200.0
func _physics_process(delta):
var steer_val = 0.0
var throttle_val = 0.0
var brake_val = 0.0
if Input.is_action_pressed("forward"):
throttle_val = 1.0
elif Input.is_action_pressed("brake"):
brake_val = 0.5
if Input.is_action_pressed("left"):
steer_val = 1.0
elif Input.is_action_pressed("right"):
steer_val = -1.0
engine_force = throttle_val * MAX_ENGINE_FORCE
brake = brake_val * MAX_BRAKE
steering = lerp(steering, steer_val * MAX_STEERING, STEERING_SPEED * delta)
To find the speed of my vehicle:
speed_kmh = linear_velocity.lenght()
And to find the maximum speed it can do:
maximum_speed_it_can = int(MAX_ENGINE_FORCE / 0.5567928730512249)
This gives me approximately the maximum speed the car can actually do.