godot-docs icon indicating copy to clipboard operation
godot-docs copied to clipboard

Your First 3D Game: Documentation for "Killing the Player" results in Error

Open DoctorWeirdPHD opened this issue 3 years ago • 5 comments

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

DoctorWeirdPHD avatar Jul 13 '22 17:07 DoctorWeirdPHD

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 🤣

Bandito11 avatar Jul 31 '22 07:07 Bandito11

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
...

armorup avatar Oct 23 '22 19:10 armorup

I'm a bit new to Godot and making code contributions. Do I just fix the problem and make a pull request?

armorup avatar Oct 23 '22 19:10 armorup

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.

armorup avatar Oct 23 '22 21:10 armorup

It is explained, just in the next section and not before. Seems like this wasn't accounted for in the flow of the lesson.

YuriSizov avatar Feb 04 '23 20:02 YuriSizov