What is a add_child ( ) ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Harshvardhan

How a add_child ( ) is different from creating a new node as a child ?

Can someone explain i am so confused…

:bust_in_silhouette: Reply From: JCNegar

add_child() does the exact same thing as adding a new child using the editor. The only difference is that add_child() can be done programmatically giving you more flexibility since you’ll be able to add children to your nodes during runtime. An example where the add_child() comes in handy is when for example instancing a bullet in your scene. You can’t do it using the editor but can use add_child() instead