Why is my character not moving

I am making a game but the problem is that my character plays the animation but is not moving.
Someone please explain what I did wrong. My script is attached below:

extends CharacterBody3D
class_name Knight

const SPEED = 5.0
const JUMP_VELOCITY = 4.5

@export var speed = 5.0
@export var acceleration = 4.0
@export var jump_speed = 8.0
@export var rotation_speed = 12.0
@export var mouse_sensitivity = 0.0015

var gravity = ProjectSettings.get_setting(“physics/3d/default_gravity”)
var jumping = false
var attacks = [
“1H_Melee_Attack_Slice_Diagonal”,
“1H_Melee_Attack_Chop”,
“1H_Melee_Attack_Stab”,
“1H_Melee_Attack_SLice_Horizontal”
]

@onready var spring_arm = $SpringArm3D
@onready var model = $Rig
@onready var anim_tree = $AnimationTree
@onready var anim_state = $AnimationTree.get(“parameters/playback”)

func _physics_process(delta):
velocity.y += -gravity * delta
get_move_input(delta)

move_and_slide()
if velocity.length() > 1.0:
	model.rotation.y = lerp_angle(model.rotation.y, spring_arm.rotation.y, rotation_speed * delta)

func get_move_input(delta):
var vy = velocity.y
velocity.y = 0
var input = Input.get_vector(“left”, “right”, “forward”, “backward”)
var dir = Vector3(input.x, 0, input.y).rotated(Vector3.UP, spring_arm.rotation.y)
velocity = lerp(velocity, dir * speed, acceleration * delta)
var vl = velocity * model.transform.basis
anim_tree.set(“parameters/IWR/blend_position”, Vector2(vl.x, -vl.z) / speed)
velocity.y = vy

func _unhandled_input(event):
if event is InputEventMouseMotion:
spring_arm.rotation.x -= event.relative.y * mouse_sensitivity
spring_arm.rotation_degrees.x = clamp(spring_arm.rotation_degrees.x, -90.0, 30.0)
spring_arm.rotation.y -= event.relative.x * mouse_sensitivity
if event.is_action_pressed(“attack”):
anim_state.travel(attacks.pick_random())

(Please use the </> button here to format your code properly.)

At a glance, I don’t see anything that seems wrong about your code.

I copied your code into a fresh project, and it seems to work fine.

Have you tried printing the velocity values? Are they what you expect? Does gravity work?

You might need to post more info. A screenshot of your scene tree and characterbody’s inspector values would help.

I will post them as soon as possable