Your First 3D Game: Documentation for "Killing the Player" results in Error
Your Godot version: 3.4.4
Issue description: At the end of the section titled Hitbox with the Area Node we are prompted to:
Try the game again by pressing F5. If everything is set up correctly, the character should die when an enemy runs into it.
However, without connecting the players hit signal, Main.gd will have no way of detecting the queue_free() on the Player Node resulting in an Invalid get index 'transform' (on base: 'null instance') thrown from:
func _on_MobTimer_timeout():
#...
var player_position = $Player.transform.origin
#...
URL to the documentation page: https://docs.godotengine.org/en/stable/getting_started/first_3d_game/07.killing_player.html#hitbox-with-the-area-node
I'm getting the same issue, but the fix should simply be to move the quoted message right to the end of the documentation. I was scratching my head until I decided to read a bit below 🤣
I am also getting the same problem. Even after stopping the mob timer, I get the error:
Invalid get index 'transform' (on base: 'null instance').
Not sure if this is the best way, but I fixed it by adding a null check to this method in the Main.gd script:
func _on_MobTimer_timeout():
...
if $Player != null:
var player_position = $Player.transform.origin
...
I'm a bit new to Godot and making code contributions. Do I just fix the problem and make a pull request?
Ok, I think I figured out the issue. Either I missed instructions from a previous page, or the documentation doesn't give instructions to connect the 'hit' signal of Player.gd to the '_on_Player_hit' method in the Main.gd script.
It is explained, just in the next section and not before. Seems like this wasn't accounted for in the flow of the lesson.