[C#] lerp doesn't appear to be working for acceleration

Godot Version

4.7.1

Question

hey, i’m trying to follow some tutorials for creating a 2d platformer and i’m running into this issue where lerping doesn’t appear to be working? my goal here is to try to have the player accelerate from 0 speed to their target walking speed, but it appears to just multiply the “to” value by the “weight” value

my horizontal movement code:

// kb inputs
if (Input.IsActionPressed("move_left"))
{
    movementDir -= 1;
    }
    if (Input.IsActionPressed("move_right"))
    {
        movementDir += 1;
    }
    if (movementDir != 0)
    {
        velocity.X = Mathf.Lerp(velocity.X, movementDir * horizontalSpeed, acceleration);
    }

velocity is a local variable for Vector2, movementDir is an int, horizontalSpeed is a float, and acceleration is also a float

here’s how my log looks if i attempt to log my velocity:

image

would anyone know a better option than lerp or a way to fix this jank? thank you if you decide to help

In C#, you cannot directly modify the X or Y value of a Vector2 like you would in GDScript, you need to create a new Vector2 variable then set that as the new variable, with the Y value being the same as before.

i’m not sure i understood this very well, since i tried to follow the instructions and ended up with the same issue as before; could you give me an example of what you’re saying?