Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | hello64 |
So i am trying to make a racing game,
but Drifting has been a problem from 2 days
my car node is a vehicle body
pls help
here is my code
extends VehicleBody
export var Steer = 0.4
export var Speed = 10.0
export var MaxRPM = 1000
var accel = 0
func _physics_process(delta):
steering = lerp(steering, Input.get_axis("D", "A") / (5 + (engine_force / 5)), delta * 20)
engine_force = Input.get_axis("W", "S") * (-accel + -Speed)
if Input.is_action_pressed("W") or Input.is_action_pressed("S"):
accel += delta * 2
if accel > MaxRPM:
accel = MaxRPM
else:
accel = 0
brake = lerp(brake, Input.get_action_strength("Brake"), delta)