Area2d stays hit after player dies in a certain way

You need to make sure that really is so at runtime. Print the signal connections from your code. If it is indeed connected, then the problem can only be in collision layers/masks setup.

yeah, i did that and got errors because it was already connected

also dying normally when not touching the timer works fine, and the timer doesn’t even touch the physics at all

# handle death
func _on_hurtbox_body_entered(_body: Node2D) -> void:
	print("dying maybe")
	die()

func die():
	if dying:
		print("cant die")
		return
	dying = true
	print("die")
	WalkFx.emitting = false
	ColorFx.emitting = false
	set_physics_process(false)
	AudioController.play_die()
	Camera.add_trauma(0.2)
	add_effect(ExplosionScene, true)
	Sprite.visible = false
	velocity = Vector2.ZERO
	get_tree().create_timer(0.4).timeout.connect(reset_boxes)

func reset_boxes():
	get_tree().call_group("reset", "reset")
	get_tree().create_timer(0.1).timeout.connect(respawn)

func respawn():
	position = Spawn.position
	color = 0
	Sprite.visible = true
	set_physics_process(true)
	can_change_color = true
	dying = false

this is the updated part of the player script, the bug still exists, I’ve figured out that the actual dying logic isn’t a problem already tho but at least it doesn’t use await ig

Let’s see your hurtbox signal connections and your collision layers and masks.

The first thing you need to do is to make sure that _on_hurtbox_body_entered() prints when things collide.

as i have already said before - when it hasn’t bugged out it prints correctly but after the timer is triggered it doesnt print.

Here are the physics layers:

Hurtbox (area2d) collision:

Tilemap that is linked to the death layer:

image

(there are death hitboxes inside the tiles so if the player clips into a wall they die, because of the main mechanic of the game that is very common)

What exactly do you mean by “after the timer is triggered”? After it runs out or after you start it? Try not calling die() from that signal handles. Let it only print. How does that behave in respect to timer?

Btw you haven’t shown the signal connections.

what signal connections?
i already said that in the players ready function die is binded to the timer_done function and showed the hurtbox function which is connected via the editor

also by “timer triggered” i mean after the player interacts with the start line and start_timer() is called

All of them. Post the editor screenshot that shows your scene tree and signal connections.

like in every scene or is there a way to view all of them?

Whatever it takes to best communicate the whole situation. Remember that debugging without being able to inspect and run the project is extremely hard. You need to provide as much information as you can. We don’t see your screen and can’t read your mind. Things that may look self evident to you will not be self evident to someone who never seen your project. Provide the full context or post the whole project. Otherwise we will be running in circles for a long time.

TimerController signals:

image

Player signals:

please excuse the messy player scene but here is everything that i think is relevant/ connected to the issue

i could always put the project on github if that helps?

Layers look fine tho, hurtbox on death / masking death, tiles on death. Timer signals aren’t the problem either.

If “dying maybe” never prints, body_entered isn’t firing. Common case with this setup: you’re already overlapping the death tiles (or still overlapping after respawn), so Godot never sends a new enter.

Quick check: after start_timer(), walk into spikes without having died yet.

If it still doesn’t print → something else is off.
If it only breaks after a death/respawn while the timer was on → stuck overlap.
After respawn (and maybe when the race starts), poke the hurtbox:

hurtbox.set_deferred("monitoring", false)
hurtbox.set_deferred("monitoring", true)
# or kill anything already inside:
for b in hurtbox.get_overlapping_bodies():
	die()
	break

call_group("reset", "reset") is also worth a look, if anything in that group turns monitoring off or moves collision, that’d match “works until the race/death flow runs.”

ps: If you can dump a minimal project (or the GitHub link), that’ll settle it faster than more screenshots.

The glitch only happens if you die when the timer is running.

All the reset thing does is reset these pushable boxes:

extends CharacterBody2D

const FRICTION = 0.8
@export var GRAVITY = 1300.0

var start_position: Vector2

func _ready():
	start_position = global_position

func reset():
	global_position = start_position
	velocity = Vector2.ZERO

func _physics_process(delta):
	if not is_on_floor():
		velocity.y += GRAVITY * delta
	else:
		velocity.x *= FRICTION
	
	move_and_slide()

Since i started making this project before i knew how to use github it’s not on there yet, I’ll get it on there now

how could i allow you to view it but not make it public? do i need your github username?

If you make a minimal project that reproduces the bug, there’s no problem in having it public. You might even figure it out yourself during the process of making it. Or just put up the whole project as it is.

The bug is likely caused by something else you’re not even aware of somewhere in the project. When catching bugs, isolation is the key. Print as much stuff as possible and/or use debugger breakpoints to see what is happening with the variable values and where the code is going. Print even the things you think “obviously” have nothing to do with the bug. Also comment out anything that is not absolutely required to run to reproduce the bug. By doing all this you can step-by-step eliminate pieces of code from being suspect, narrowing down the probable culprits. Continue doing this to gradually zero-in on the bug. It’s detective work. This is a skill you absolutely need to develop if you’re interested in programming in any serious capacity.

i have stripped down the project to just the timer starters and tileset and player and the bug no longer occurs

You can now try adding stuff back little by little until it re-appears. The last thing you added is the likely cause.

just to make sure it wasn’t just in that level, i tried it in another level and it now behaves differently. but it still acts the same in the first level i found the bug in

the way it acts differently in this other level is that you cant die when the timer is active which is so confusing

edit: nevermind it just sometimes kills you or something i don’t even know whats happening

in a similar setup to the one i showed in the stripped down version of the game but in the actual project this time the glitch isn’t re-creatable, ill try adding stuff to the level until it does happen

found what triggers the bug i think, and it isn’t even related to the timer :sob:

when you die to a different colored tile maybe? the bug happens. im not sure, it seemed like it was when you die in the inside of a tile but then at the end of this video dying to a blue spike triggers the bug

no matter what caused it if i had to guess its to do with the area2d staying triggered