Coding Global Background
Coding Global

whats wrong with my godot car driving/drifting code?

Archived a year ago
1
1 messages
0 members
a year ago
Open in Discord
S
Tissle is a triangle

i cant figure oot how to make my car drift i got the movement down but then i tried implementing drifting but i cant figure it ou my project wont run when i try with this code THE CODE: extends VehicleBody3D var max_rpm = 1000 var max_torque = 200 var normal_steering_factor = 0.4 var drift_steering_factor = 0.6 var normal_friction = 1.0 var drift_friction = 0.3 func _process(delta): car_reset() func _physics_process(delta): var steering_factor = normal_steering_factor var friction_factor = normal_friction if Input.is_action_pressed("drift"): steering_factor = drift_steering_factor friction_factor = drift_friction steering = lerp(steering, Input.get_axis("right", "left") * steering_factor, 5 * delta) var acceleration = Input.get_axis("back", "forward") var rpm = $backleftwheel.get_rpm() $backleftwheel.engine_force = acceleration * max_torque * (1 - rpm / max_rpm) $backrightwheel.engine_force = acceleration * max_torque * (1 - rpm / max_rpm) # Adjust friction based on drifting $backleftwheel.friction_slip = friction_factor $backrightwheel.friction_slip = friction_factor func car_reset(): if Input.is_action_just_pressed("reset rotation"): rotate_z(180)

whats wrong with my godot car driving/drifting code?

Replies (1)