I'm working my way through the "Godot 3 Complete Developer Course - 2D and 3D" course on Udemy. At the end of the Space Attack section is the assignment to add a health bar for the player. Here is a link to download my full project. http://www.markalmighty.com/f/ez/downloader.php?d=godot&f=SpaceAttack_by_MarkAlmighty.zip

The game crashes when the player ship gets hit and I've included an argument with the emit_signal in Player.gd, Line 63:

func _on_Player_health_changed(new_health):
	print(new_health) #<-- WORKS!!!
	emit_signal("health_changed", new_health)

The debugger output: Debug Process Started OpenGL ES 3.0 Renderer: GeForce GTX 1060 6GB/PCIe/SSE2 465.249115 drivers/unix/netsocketposix.cpp:190 - Socket error: 10054 Debug Process Stopped

If I remove the "new_health" argument, there's no crash. (Of course, the LifeBar also doesn't get updated.)

After quite a bit of debugging, I finally found the issue! The issue is in the Player.tscn file. You have the health_changed signal connected through the editor to the _on_player_health_changed function. This causes an infinite loop, because the on_player_health_changed function emits health_changed, which is crashing the game.

To fix the issue, just remove the connected health_changed signal in Player.tscn and the game should work without crashing. You might also need to disconnect the signal from the instanced Player.tscn in the main game scene as well. If that does not work, I can provide the working project I debugged.

Hopefully this helps! (Side note: Welcome to the forums)

@TwistedTwigleg said: After quite a bit of debugging, I finally found the issue! The issue is in the Player.tscn file. You have the health_changed signal connected through the editor to the _on_player_health_changed function. This causes an infinite loop, because the on_player_health_changed function emits health_changed, which is crashing the game.

To fix the issue, just remove the connected health_changed signal in Player.tscn and the game should work without crashing. You might also need to disconnect the signal from the instanced Player.tscn in the main game scene as well. If that does not work, I can provide the working project I debugged.

Hopefully this helps! (Side note: Welcome to the forums)

This, along with the response I got here, helped me go in the right direction. So thank you very much!

3 years later