Killzone does not work

Could someone explain why this killzone doesn’t work?
It registers collision and the text “aa” gets displayed but there is no reset.

extends Area2D

@onready var timer = $Timer
func _on_body_entered(body):
print(“aa”) # Replace with function body.

timer.start()

func _on_timer_timeout():
get_tree().reload_current_scene()

There is an error message:
W 0:00:00:0765 The parameter “body” is never used in the function “_on_body_entered()”. If this is intended, prefix it with an underscore: “_body”.

Sorry, with your code pasted that way it’s difficult to tell what the actual spacing on it is.

Is it something like this?

func _on_body_entered(body):
    print("aa")
    timer.start()

If so, you need to confirm that the timeout signal is actually connected. You should see a green mark next to the on_timer_timeout function if so.

You could also try to print the timer’s timeleft in a process function or print something when getting to the timeout function. I suspect you’re not getting to the timeout function.

1 Like

Hello and thank you for answering.
I tried to fix the thing for maybe an hour or two but finally gave up. I’m not sure exactly what went wrong but I think it had something to do with masks or ordering. I just followed the tutorial through up until the point where I’d gone lost, so I’m back on track now.

1 Like