Hello!
I am a beginner at Godot, and I am currently making a flappy bird clone. The trees are the obstancles and the player is a plane
I made it whenever the player collides with a tree or go offscreen, you would die and restart the game. It detects when it's offscreen by using a visibilitynotifier2d and connecting a screen_exited signal to my script. However, when I collide with a tree, it doesn't let me restart the game even though they call the exact death function.
Here is my current code for the player detecting and killing the player:
func _on_Area2D_body_entered(body):
print(body)
if "trees" in body.name:
#call the exact same death function
death()
func _on_VisibilityNotifier2D_screen_exited():
#call the exact same death function
death()
#death function
func death():
$death.play()
Global.pause = true
Global.gamestart = true
get_parent().get_node("CanvasLayer/restarttext").visible = true
get_parent().get_node("CanvasLayer/score2").visible = true
func _process(delta):
if Global.gamestart == false:
return
if Input.is_action_just_pressed("ui_up"):
Global.gamestart = false
Global.score = 0
get_tree().reload_current_scene()
What I am doing wrong, and sorry if this answer is obvious, I'm a complete beginner