Import nodes to a specific position

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

In my game you are a spaceship and you have to avoid meteorites. the meteorites should be placed in a certain place.
here is the script:

var myNode = preload(“res://myNode.tscn”)

func add_myNode_to_Game(): 
	 var myNode_instance =  myNode .instance() 
	 get_tree().get_root().add_child(myNode_instance)

	myNode_instance.global_transform = global_transform

What’s the problem here? You need to be more specific. What do you want to do and what’s not working.

MrEliptik | 2021-03-22 21:44

I want to add the meteorites to a certain position at the top of the screen (it should be a mobile game) and I need to know how to add in this script where I can import the node.

GammerSly | 2021-03-23 08:03

:bust_in_silhouette: Reply From: exuin

You have a spelling error on line 4: myNoder_instance should be myNode_instance. Also, I don’t recommend that you mix snake case and camel case like that.