Firing bullets
Now, you need instances of the bullet to be created whenever the player fires. However, if you make the bullet a child of the player, then it will move and rotate along with the player instead of moving independently. Instead, the bullet should be added as a child of the main scene. One way to do this would be to use get_parent().add_child(), since the Main scene will be the parent of the player when the game is running. However, this would mean you could no longer run the Player scene by itself like you have been doing, because get_parent() would produce an error. Or, if in the Main scene you decided to arrange things differently, making the player a child of some other node, the bullet wouldn't be added where you expect. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access