Why can't my character run anymore?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By sunscreenlotion

Beginner newbie here, I was working on y-sorting when all of a sudden my character isn’t able to run across the screen anymore. Whenever I hit play the screen just vibrates if I try moving up down left or right. Below are the imgur links for the images and screenshots, let me know what other information I need to share about this. Thank you!

How the nodes are positioned: Imgur: The magic of the Internet
Inspector for player: Imgur: The magic of the Internet
Inspector for tilemap: Imgur: The magic of the Internet

:bust_in_silhouette: Reply From: Booba

I am fairly new to scripting but can you provide your movement code i will try to help

extends CharacterBody2D

@export var speed = 400
var screen_size
var current_dir = "none"

func _ready():
	screen_size = get_viewport_rect().size

func _process(delta):
	var velocity = Vector2.ZERO
	if Input.is_action_pressed("up"):
		velocity.y -= 1
	if Input.is_action_pressed("down"):
		velocity.y += 1
	if Input.is_action_pressed("right"):
		current_dir = "right"
		velocity.x += 1
	if Input.is_action_pressed("left"):
		current_dir = "left"
		velocity.x -= 1

	if velocity.length() > 0:
		velocity = velocity.normalized() * speed
	position += velocity * delta
	position.x = clamp(position.x, 0, screen_size.x)
	position.y = clamp(position.y, 0, screen_size.y)

func compute_animation(current_dir):
	var anim = $AnimatedSprite2D
	if current_dir == "right":
		anim.flip_h = true
		anim.flip_h = false

func handleInput():
	var moveDirection = Input.get_vector("left", "right", "up", "down")
	velocity = moveDirection * speed

func _physics_process(delta):

Here it is, sorry it looks a little messy

sunscreenlotion | 2023-06-14 13:55