My First Game: Start button not working.

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

I am running through the “My first game” tutorial and I am getting close to the end of the project. I’m stuck at the conclusion of the HUD section. The tutorial had me create a function: “func show_game_over():”. Then it asked me to “connect the timeout() signal of MessageTimer and the pressed() signal of StartButton and add the following code to the new functions:”

func _on_StartButton_pressed():
    $StartButton.hide()
    emit_signal("start_game")

func _on_MessageTimer_timeout():
    $Message.hide()

The problem is that I dont know how to connect the “timeout()” signal of MessageTimer to the pressed() signal of StartButton. I feel like something is missing here. At first I missed this part and entered the two functions above without creating a connection to the signal because I couldnt find a signal to connect, but I think I need to make a signal connection somehow because when I run the game, the startbutton does not work and the “Get Ready” messages overlays the game title as the below screenshot shows:

Attached is also the editor screen of where I am at in the code, and a screen shot of a section of tutorial where i’m stuck.


Thank you in advanced for your help. I tried to be as descriptive as possible without making this post too complicated.

:bust_in_silhouette: Reply From: IceExplosive

Select MessageTimer in left panel (you should open HUD scene, or where that timer is located) and in the right panel, you’ll see list of Signals… under the Node tab.

In the code printscreen you’ve provided there are signals for HUD node visible.

Timer will have a timeout() signal… double left click on it and it will open a pop-up window where you can connect it to function.

Ok I did not know that I had to have the HUD scene selected for this. But all it did was add a new function “pressed()” and I do not know what to do at this point in relationship to the below instructions:

Connect the timeout() signal of MessageTimer and the pressed() signal of StartButton and add the following code to the new functions:

func _on_StartButton_pressed():
    $StartButton.hide()
    emit_signal("start_game")

func _on_MessageTimer_timeout():
    $Message.hide()

Screenshot of my editor of the situation:

trinsic | 2021-07-10 18:56

I’ve never done that tutorial, so I might be wrong, but it wants you to do two different conenctions.

You’ve connected timeout() signal to a pressed() functions which is wrong

Tutorial says:
Connect the timeout() signal of MessageTimer
and the pressed() signal of StartButton
and add the following code to the new functions:

So my take is that you should paste provided code into a HUD script:

func _on_StartButton_pressed():
    $StartButton.hide()
    emit_signal("start_game")

func _on_MessageTimer_timeout():
    $Message.hide()

And do 2 connections.
MessageTimer.timout() signal to _on_MessageTimer_timeout() function
and StartButton.pressed() signal to _on_StartButton_pressed() function

IceExplosive | 2021-07-10 19:03

Alright so I was able to connect those signals correctly but I’m still stuck. I’m near the end of this tutorial. Im at the end of the HUD section and am attempting to test the game. The game starts with the message “Get Ready” overlays the “Dodge the Creeps”. When I press the start button and the text stays on the screen and the mob function executes correctly, but I do not see the player load into the game. The screenshots of the gotdot editor and the debug screen are below:

I compared all of the gd scripts with the working gd scripts from the tutorial and everything looks ok. At this point I am not sure where the problem is. The dubber screen shows one error but I dont think its related:

W 0:00:00.395   The argument 'body' is never used in the function '_on_Player_body_entered'. If this is intended, prefix it with an underscore: '_body'
  <C++ Error>   UNUSED_ARGUMENT
  <Source>      Player.gd:47

Also the main scene is selected in the project settings…

Im at a loss at this point what is causing the problem. Please let me know If I need to add anything else to this question to help understand why the game is not running correctly.

trinsic | 2021-07-17 16:27

That warning is not important.

In screenshoot I see:
_on_StartButton_pressed():

which is emitting a “start_game” signal.
Is this signal connected? There has to be something that is listening to this signal and will spawn a player character.

Without full code I can only guess.

IceExplosive | 2021-07-18 14:31