Import scene to a specific point

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

In my game meteorites should appear at different places (screen edge) which man then must avoid. now I would like to know how I could build such a script into my code (I would like to import a scene) Here is my code:

var myNode = preload("res://myNode.tscn")

    func add_myNode_to_Game(): 
         var myNode_instance =  myNode .instance() 
         myNode_instance.global_transform = global_transform
:bust_in_silhouette: Reply From: Spyrex

Just set the position of the Node to where it should appear, directly after instancing it.


myNode_instance.global_transform = global_transform

You set the position of the myNode_instance to the position of the node that called this expression. Just replace it with the specific point using global_transform.origin.