extends State class_name AccelDecel @export var acceleration = 2000 @export var deceleration = 1500 func movement(velocity_x, speed, input_direction, v_mult, v_push, delta): var target_speed = speed * input_direction * v_mult + v_push if input_direction != 0: return move_toward(velocity_x, target_speed, acceleration * delta) return move_toward(velocity_x, 0, deceleration * delta) func turnmovement(velocity_x, speed, input_direction, v_mult, v_push, delta, direction_locked, facing_direction): var vx = movement(velocity_x, speed, input_direction, v_mult, v_push, delta) var fd = facing_direction if not direction_locked and input_direction != 0 and sign(input_direction) != facing_direction: fd = sign(input_direction) return [vx, fd]