how to make sprite kill you when toutched

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

i got 250 sprites under a Node…
how do i make it so when the player collides with the sprites/the node
he will die/respawn?

:bust_in_silhouette: Reply From: sparkart

Area2D has a “body_entered(body)” signal that you could use. You can also use the “name” property to filter for the player/object being collided:

func _on_body_entered(body) -> void:
	if body.name == "player":
		GLOBAL.player_dead()
		GLOBAL.restart_scene()