Remote Scene Tree

I’m following the Shooting Rockets part of the Alien Attack video and noticed that after pressing the spacebar a few times to instantiate rockets that when looking at the Remote Scene tree I can see the first instanced Rocket node is labelled ‘Rocket’ and then subsequent Rockets are labelled @Area2D@2, @area2D@3 etc. instead of @Rocket@2, @Rocket@3 etc. They have taken the name of the node type rather than from the name “Rocket” I have given them. It’s a minor point and not sure if I’ve missed something or this is a change in Godot?

So to be clear the Remote Scene tree looks like this on first running the game:

  • root
    • Game
    • Background
    • Player
      • Sprite2D
      • CollisionShape2D
    • Rocket
      • Sprite2D
      • CollisionShape2D

After pressing spacebar once:

  • root
    • Game
    • Background
    • Player
      • Sprite2D
      • CollisionShape2D
      • Rocket
    • Rocket
      • Sprite2D
      • CollisionShape2D

Then further spacebar pressed shows:

  • root
    • Game
    • Background
    • Player
      • Sprite2D
      • CollisionShape2D
      • Rocket
      • @Area2D@2
      • @Area2D@3
    • Rocket
      • Sprite2D
      • CollisionShape2D

I guess because the first instanced Rocket is called ‘Rocket’ that additional ones are grouped underneath?

I’ve now read the Godot documentation and the solution is to set the force_readable_name argument of add_child function to true:

add_child(rocket_instance, true)

This doesn’t put the @ signs in the name but names each instance as Rocket with a number added to make it a unique .

3 Likes

Privacy & Terms