Hey guys for anyone else wondering I've figured it out, here's what it looks like. Not the best but at least it works :)
extends CharacterBody2D
@export var speed = 140
func _process(_delta):
walking()
func walking():
#movement
var direction = Vector2()
#animation
var fuck = $animation
#walking is possible thanks to this
if Input.is_action_pressed("ui_right"):
direction.x += 1
if Input.is_action_pressed("ui_left"):
direction.x -= 1
if Input.is_action_pressed("ui_down"):
direction.y += 1
if Input.is_action_pressed("ui_up"):
direction.y -= 1
#animation
match direction:
Vector2(1, 0):
fuck.play()
fuck.set_animation("right")
Vector2(-1, 0):
fuck.play()
fuck.set_animation("left")
Vector2(0, 1):
fuck.play()
fuck.set_animation("down")
Vector2(0, -1):
fuck.play()
fuck.set_animation("up")
# more movement junk.
# make sure it's placed after the match statement.
direction = direction.normalized()
velocity = direction * speed
move_and_slide()
#animation stops
if velocity == Vector2.ZERO:
fuck.stop()