Godot Debug Not working, thoughts?

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

So here I am just jaunting along on my player script, I finish it, try to run the player instance on a basic test scene and low and behold, the debugger freezes, is it my code, or is it another issue?

Here is what's happening

Here’s my code:

extends KinematicBody2D

#SIMPLE STATE MACHINE FOR ANIMATIONS
enum {
	IDLE,
	IDLE_SWORD,
	WALK,
	RUN,
	ATTACK1,
	ATTACK2,
	ATTACK3,
	JUMP,
	CROUCH,
	CLIMB,
	FALL,
	HIT,
	DEATH,
	SLIDE,
	NONE
}
#STATE CONTROL VARIABLES
var state = IDLE
var prev_state = IDLE

#PLAYER CHILDREN
onready var sprite = $AnimatedSprite
onready var attackright = $AttackBox1
onready var attackleft = $AttackBox2
onready var collisionlow = $CollisionShapeLow
onready var collisionstill = $CollisionShapeStill
onready var collisionmove = $CollisionShapeMove
var animplay



func _ready():
	animplay = $AnimationTree.get("parameters/playback")



#MOVEMENT VARIABLES
var dir = 0
var velocity = Vector2()
var MAX_SPEED = 100
var ACCEL = 0.25
var DEACCEL = 0.1
var JUMP_FORCE = -300
var GRAV = 1000
var attack_state = 0
var attack_num

func _process(delta):
	process_input(delta)
	process_movement(delta)
	process_animations()



func process_input(_delta):
	#CHECK TO SEE IF PLAYER IS DEAD
	while(state != DEATH):
		#PROCESS X-AXIS INPUT
		if Input.is_action_pressed("left"):
			dir -= 1
			state = WALK
			if Input.is_action_pressed("run"):
				state = RUN
			elif Input.is_action_pressed("crouch"):
				state = CROUCH
		elif Input.is_action_pressed("right"):
			dir += 1
			state = WALK
			if Input.is_action_pressed("run"):
				state = RUN
			elif Input.is_action_pressed("crouch"):
				state = CROUCH
		else:
			state = IDLE
		
		#PROCESS Y-AXIS INPUT
		if Input.is_action_pressed("jump") and is_on_floor():
			state = JUMP
		elif velocity.y < 0.0 and !is_on_floor():
			state = FALL
		
		#SPECIAL STATE CASES
		#ATTACKS
		if Input.is_action_pressed("action_primary") and (state != ATTACK1 or state != ATTACK2 or state != ATTACK3):
			state = ATTACK1
			attack_num = 1
			attack_state = OS.get_ticks_msec() + 1000
		if OS.get_ticks_msec() < attack_state and Input.is_action_pressed("action_primary"):
			if state == ATTACK1:
				state = ATTACK2
				attack_num = 2
				attack_state = OS.get_ticks_msec() + 1000
			elif state == ATTACK2:
				state = ATTACK3
				attack_num = 3
				attack_state = OS.get_ticks_msec() + 1200
		
		#CHECK IF ATTACK ANIM IS PLAYING
		if attack_state > OS.get_ticks_msec():
			match attack_num:
				1:
					state = ATTACK1
				2:
					state = ATTACK2
				3:
					state = ATTACK3
		else:
			if attack_num != -1:
				attack_num = -1



func process_movement(delta):
	#CHECK FOR MOVEMENT TYPE IN THE X-AXIS
	match state:
		IDLE:
			velocity.x = lerp(velocity.x, 0.0, DEACCEL)
		WALK:
			velocity.x = lerp(velocity.x, dir * MAX_SPEED, ACCEL)
		RUN:
			velocity.x = lerp(velocity.x, (dir * MAX_SPEED * 2.0), ACCEL)
		CROUCH:
			velocity.x = lerp(velocity.x, 0.0, DEACCEL)
		ATTACK1:
			velocity.x = lerp(velocity.x, 0.0, DEACCEL)
		ATTACK2:
			velocity.x = lerp(velocity.x, 0.0, DEACCEL)
		ATTACK3:
			velocity.x = lerp(velocity.x, 0.0, DEACCEL)
	#CHECK FOR MOVEMENT TYPE IN THE Y-AXIS
	if state == JUMP and is_on_floor():
		velocity.y = JUMP_FORCE
	elif !is_on_floor():
		velocity.y += GRAV * delta
	else:
		velocity.y = 0.0
	#DO MOVEMENT
	velocity = move_and_slide(velocity, Vector2.UP)



func process_animations():
	#SYNC SPRITE TO MOVEMENT DIRECTION
	if velocity.x > 0:
		sprite.flip_h = false
	elif velocity.x < 0:
		sprite.flip_h = true
	#SYNC ANIMATION TO STATE
	if state != prev_state:
		prev_state = state
		match state:
			IDLE:
				animplay.travel("idle")
			IDLE_SWORD:
				animplay.travel("idle_sword")
			WALK:
				animplay.travel("walk")
			RUN:
				animplay.travel("run")
			ATTACK1:
				animplay.travel("attack1")
			ATTACK2:
				animplay.travel("attack2")
			ATTACK3:
				animplay.travel("attack3")
			JUMP:
				animplay.travel("jump")
			CROUCH:
				animplay.travel("crouch")
			CLIMB:
				animplay.travel("climb")
			FALL:
				animplay.travel("fall")
			HIT:
				animplay.travel("hit")
			DEATH:
				animplay.travel("death")
			SLIDE:
				animplay.travel("slide")
:bust_in_silhouette: Reply From: Amateur.game.dev.

Try changing from GLES3 to GLSE2, in the top right corner next to “build”. It worked for me.

I tried that, it didn’t work

Moldor2 | 2020-09-25 13:38

Well you can go to project settings > rendering > quality > driver and changing to gles2 you may have to adjust your scene, also what error does Godot give you when your debugger fails.

Brightlight studios | 2020-09-25 14:11

I’m not getting any errors it just freezes completely, I also tried your method to no avail. O appreciate the help though, thanks.

Moldor2 | 2020-09-25 14:46

:bust_in_silhouette: Reply From: Moldor2

I figured it out, there seems to be some bug with the while statement in GDscript

Good for you you should probably use an if statement the while statement completely stops everything until a certain condition is fulfilled it’s a pretty annoying piece

Brightlight studios | 2020-09-25 18:05

1 Like
:bust_in_silhouette: Reply From: BumfuzzledGames

The problem is your while loop. Remember that Godot is an iterative engine, your scripts must return from _process or _physics_process before the engine can continue. If your while loop doesn’t end it’ll just loop forever and the whole application will lock up.

Check for death with a simple if statement, don’t wrap all the input logic in a while statement.