how to add_child() with additional special properties?

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

Look, i have a scene for bullet and i want to add it to main scene ,but i want to make it with additional properties like rotation or linear_velocity. Is there any way to do that

or maybe prevent change of position of child node when parent node is rotating (im gonna ask this in the next question if i wont get help from this one)

thank you

:bust_in_silhouette: Reply From: Enfyna

You can edit properties before adding them. Example code :

func _ready():
    #Get scene and instantiate it
    var bulletInstance = load("res://bullet.tscn").instantiate() 
    bulletInstance.rotation = 45 # Change Properties
    # I only did rotation but you can do anything you want
    add_child(bulletInstance) # Add it to the scene

I dont think you can prevent change of position of child node when parent node is moving. Easiest way would be to make them siblings.