How to move character without cancelling buttons and keep animations working properly?

Godot Version

4.2.2.stable.official

Question

I am attempting to get my character in my test to move in specific directions without the animations bugging, and I seem to have over-engineered this…

On top of that, I seem to be unable to move my character in the debugger. What I seem to have done is completely break that. Not sure exactly what I’m doing wrong here, and I’m a beginner so I might need a bit of further explanation.

I apologize, my finger slipped when I hit the “Post” button and I didn’t have my code included. I have solved the problem but I’m wondering if this was still over-engineered.

I should also mention I was following a hodgepodge of tutorials, so this is… a bit weird…

extends CharacterBody3D


const SPEED = 1.5
const JUMP_VELOCITY = 3.0

 Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
var facing = 0; #left or right, left = 0
var facing2 = 0; #up or down, down = 0



func _process(_delta):
	if Input.is_action_just_pressed("ui_right"):
		facing=1
	elif Input.is_action_just_pressed("ui_left"):
		facing=0
	elif Input.is_action_just_pressed("ui_up"):
		facing2=1
	elif Input.is_action_just_pressed("ui_down"):
		facing2=0
	if Input.is_action_pressed("ui_right") and facing2==0 and not \
	Input.is_action_pressed("ui_left"):
		$AnimatedSprite3D.play("Right")
	elif Input.is_action_pressed("ui_right") and facing2==1 and not \
	Input.is_action_pressed("ui_left"):
		$AnimatedSprite3D.play("UpRight")
	elif Input.is_action_pressed("ui_left") and facing2==0 and not \
	Input.is_action_pressed("ui_right"):
		$AnimatedSprite3D.play("Left")
	elif Input.is_action_pressed("ui_left") and facing2==1 and not \
	Input.is_action_pressed("ui_right"):
		$AnimatedSprite3D.play("UpLeft")
	elif Input.is_action_pressed("ui_up") and facing==0 and not \
	Input.is_action_pressed("ui_down"):
		$AnimatedSprite3D.play("UpLeft")
	elif Input.is_action_pressed("ui_up") and facing==1 and not \
	Input.is_action_pressed("ui_down"):
		$AnimatedSprite3D.play("UpRight")
	elif Input.is_action_pressed("ui_down") and facing==0 and not \
	Input.is_action_pressed("ui_up"):
		$AnimatedSprite3D.play("Left")
	elif Input.is_action_pressed("ui_down") and facing==1 and not \
	Input.is_action_pressed("ui_up"):
		$AnimatedSprite3D.play("Right")
	else:
		$AnimatedSprite3D.play("Idle")


func _physics_process(delta):
	if not is_on_floor():
		velocity.y -= gravity * delta

	if Input.is_action_just_pressed("ui_accept") and is_on_floor():
		velocity.y = JUMP_VELOCITY

	var dirx = 0
	var dirz = 0
	dirx = int(Input.is_action_pressed("ui_right")) - int(Input.is_action_pressed("ui_left"))
	dirz = int(Input.is_action_pressed("ui_up")) - int(Input.is_action_pressed("ui_down"))
	var direction = (transform.basis * Vector3(dirx, 0, dirz)).normalized()
	if direction:
		velocity.x = direction.x * SPEED
		velocity.z = direction.z * SPEED
	velocity.x = move_toward(velocity.x, 0, SPEED)
	velocity.z = move_toward(velocity.z, 0, SPEED)