I am too stupid to implement this

i just want to make it not come to an abrupt stop and glide smoothly for a while and that’s it

extends CharacterBody2D
@export var speed = 400
@export var rotation_speed = 2.5
@export var rotation_growth = 2.0
var rotation_direction = 0
var totalrotationspeed = 0
func get_input():
	rotation_direction = Input.get_axis("left", "right")
	velocity = transform.x * Input.get_axis("thrustdown", "thrustup") * speed
func _physics_process(delta: float) -> void:
	if Input.get_axis("left", "right") == 0:
		totalrotationspeed -= rotation_growth * delta
		totalrotationspeed = clampf(totalrotationspeed, 0.0, rotation_speed)
	else:
		totalrotationspeed += rotation_growth * delta
		totalrotationspeed = clampf(totalrotationspeed, 0.0, rotation_speed)
	if Input.get_axis("thrustdown", "thrustup") == 0:
		velocity = transform.x * lerpf(speed, 0.0, 0.1)
	get_input()
	rotation += rotation_direction * totalrotationspeed * delta
	move_and_slide()

and the rotation at the beginning works fine but stops instantly when released

Well, you call get_input()right after all your decelerating code. In get_input() it will set velocity to 0 if the input is 0.

I tried to rewrite your code a bit, maybe it works

extends CharacterBody2D

@export var speed = 400
@export var rotation_speed = 2.5
@export var rotation_growth = 2.0
var rotation_direction = 0
var totalrotationspeed = 0

func _physics_process(delta: float) -> void:
	rotation_direction = Input.get_axis("left", "right")
	totalrotationspeed += rotation_growth * delta * (rotation_direction if rotation_direction else -1)
	totalrotationspeed = clampf(totalrotationspeed, 0.0, rotation_speed)
	rotation += totalrotationspeed * delta
	
	var input_thrust := Input.get_axis("thrustdown", "thrustup")
	if input_thrust:
		velocity = transform.x * input_thrust * speed
	else:
		velocity *= 0.95
	
	move_and_slide()

I think @ratrogue is probably on the money, but in addition:

I’d be inclined to explicitly declare your types, so you don’t accidentally wind up with integer vars:

@export var speed:           float = 400.0
@export var rotation_speed:  float =   2.5
@export var rotation_growth: float =   2.0

var rotation_direction:      float =   0.0
var total_rotation_speed:    float =   0.0

Assuming you’re running 60fps, delta is usually going to be 1.0 / 60.0, which is roughly 0.01667. If you’re running 30fps, it’ll be 1.0 / 30.0, so roughly 0.03333. You can use that to help understand what the scaling will look like.

I’m assuming you’re using keyboard or dpad input here, since you’re not taking the magnitude of the input vector into account. If you were using a gamepad thumb stick, you’d probably want to scale the input vector by _growth.

Part of the problem, I think, is you’re using lerp() wrong. It’s a common mistake; there’s a lot of code and examples that use lerp() that way, but it doesn’t do what you want it to. lerp() is “linear interpolation”, but when you use a fixed value for the time argument, you get results that are both exponential and frame rate dependent, which is usually the opposite of what you want. If you want to slow down linearly with lerp(), you probably want something like:

const SPEED_DECAY_SECONDS: float = 4.0
var   decay_time:          float = 0.0
var   pre_velocity:        float = 0.0 # velocity when input was released.

func _drop_speed(delta: float) -> void:
    if is_nonzero(velocity):
        decay_time += delta
        velocity = lerpf(pre_velocity, 0.0, decay_time / SPEED_DECAY_SECONDS)
    

That is, lerp between two fixed speeds with a variable time between 0.0 and 1.0, and drive that time off of delta. If you do that, you get controllable, linear decay that isn’t affected by frame rate.

Each frame, without excption, you do:

rotation += rotation_direction * totalrotationspeed * delta

rotation_direction is the direct state of the input vector at that frame. When the controls are released, this will be zero, everything it multiplies will be zero as well and rotation will instantly stop changing.

i did a little bit of putting snippets here and there and it works perfectly! thanks to @ratrogue @hexgrid @normalized for making this project possible!