From 3f2f05c50dfe3406e62ace957183589a965cdc74 Mon Sep 17 00:00:00 2001 From: magnetotail Date: Sat, 12 Jun 2021 02:25:59 +0200 Subject: [PATCH] Fixed playermovement. Driving is now possible --- Playa.gd | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Playa.gd b/Playa.gd index 4d64f05..f72a379 100644 --- a/Playa.gd +++ b/Playa.gd @@ -20,13 +20,15 @@ func _physics_process(delta): else: velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta) - var steering_right = Input.is_action_pressed("ui_right") - - if steering_right: - var direction_new = direction.rotated(PI/128 * delta) - velocity = velocity.rotated(direction_new.angle()) - rotate(direction_new.angle()) - print(direction_new.angle_to(direction)) + var steer_dir = Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left") + + if steer_dir != 0: + var direction_new = direction.rotated(PI/2 * steer_dir * delta) + print(PI/8 * delta) + #print(velocity.angle_to(velocity.rotated(direction_new.angle()))) + velocity = velocity.rotated(direction.angle_to(direction_new)) + rotate(direction.angle_to(direction_new)) + #print(velocity)