The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

+1 vote

Hi guys I know how to restart the game but I do not know how can I configure an object that triggers the restart. For example in an endless runner like flappy bird are the tubes deadly for the player. How can I make the tubes deadly?

in Engine by (16 points)

Let me see if I understand this correctly. You need a state such that, when the main character is defeated (e.g. "killed"), it then resets the game? If that's correct, your game needs a "game over" trigger (the bird touching the tubes, for instance). In the case of Flappy Birds, the "game over" trigger looks like this:

  1. Move bird according to user's input.
  2. If the bird collides with a pipe (one that may have an Area2D node), go to the "game over" state.
  3. Reset the game from the beginning.

And how can I collide the bird with the object?

1 Answer

+1 vote
Best answer

Assuming you have a 2D flappy bird-type game, you need to place Area2D nodes on both the bird and the tube.

1) Create Area2D nodes for your bird and tube objects

2) Create a new script for the tube.

3) Set up an area_entered signal from the Node tab (next to the Inspector tab when you select an object in the editor). Connect the signal to the node that holds the script.

4) A new _on_Area2D_area_entered(area) function appears in the previously created script. Put your logic here. The gist of it all is that when another Area2D collides with this object, you want to check what this other Area2D is, and if it is the bird, you restart the game. You do it somewhat like this:

func _on_Area2D_area_entered(area):
    if == "Area2D":
        get_tree().change_scene(MainScreen) # change to another scene
by (1,892 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.