diff --git a/Player.gd b/Player.gd index 60cc612..4ac0b4b 100644 --- a/Player.gd +++ b/Player.gd @@ -6,13 +6,13 @@ const WALK_VELOCITY = 700 const AIR_CONTROL = 0.1 -const WALK_ACCEL = 0.1 +const WALK_ACCEL = 0.25 const WALK_DECEL = 0.1 const MOUSE_SENSITIVITY = 1.0 / 300 onready var camera = $Camera -onready var debug = get_tree().root.find_node("Debug") +onready var debug = $"../Debug" # really bad var velocity = Vector3.ZERO @@ -33,8 +33,22 @@ remote func walk(direction: Vector2): var walkVelocity = WALK_VELOCITY * walkDirectionNormalized - velocity.x = walkVelocity.y - velocity.z = - walkVelocity.x + var interpolation + + var currentVelocity = Vector2(- velocity.z, velocity.x) + if walkVelocity.dot(currentVelocity) > 0: + interpolation = WALK_ACCEL + else: + interpolation = WALK_DECEL + + debug.text = "Interpolation: " + String(interpolation) + debug.text += "\nwalkVelocity: " + String(walkVelocity) + debug.text += "\ncurrentVelocity: " + String(currentVelocity) + + # TODO add air control multiplier for mid-air movement + + velocity.x = lerp(velocity.x, walkVelocity.y, interpolation) + velocity.z = lerp(velocity.z, - walkVelocity.x, interpolation) remote func jump(): print("JUMP")