How would i add acceleration to my player?

Godot Version

v4.4.1

Question

I’m trying to add friction/acceleration/deceleration to my player, but i can’t really find any way to do it for my code specifically, I’ve tried looking for tutorials or other peoples examples but I’m not quite sure how to implement it into mine.

final x-axis movement code currently (no friction/acceleration/deceleration):
Untitled

You could do this with move_toward. Example usage:

var speed : float = 0.0
var max_speed : float = 10.0

func _process(delta : float)->void:
    speed = move_toward(speed, max_speed, 1.0)

This code increments speed by 1.0 every time _process is called. speed will not exceed max_speed.