Question
How to implement Acceleration by modifying the Code below.
Didn’t find a good youtube tutorial for godot 4.0
And a also have a basic programming logic question:
if direction: ← if directions is what? aren’t this missing something a number for example
and can someone explain my this line
velocity.x = move_toward(velocity.x, 0, speed)
move on the x axis until you reach 0 with speed?
so how to use move_toward with acceleration (or is it irrelevant)
would this work?
var acceleration = 1
var max_speed = 150
velocity.x = direction * acceleration ← But how to stop a max speed?
Any advice is appreciated, I’m just confused
var direction = Input.get_axis("move_left", "move_right")
if direction:
velocity.x = direction * speed
else:
velocity.x = move_toward(velocity.x, 0, speed)