If I have a scene that creates a sprite at position x,y, and I want to create instances of it from another scene via GDScript and want to pass in the initial x,y coordinates of the sprite: how would I accomplish this?<br /><br />Thanks!<br />Bryan

Most of the time you want to place your object in the scene that gonne be instantiated at 0/0 - it just makes things easier (so if your sprite in scene A is in another collection of nodes consider to export it again). To get it into another scene there are typically three steps to do:[list][li]instatiate[/li][li]positioning[/li][li]adding to scene tree[/li][/list]Thats why you can move your object around initially before it will be shown in the scene at all. So just use godot's moving functions and consider the origin (0/0) of the instatiated scene will be shown at the new postition (and all content relative to it).Further readings:[url=http://docs.godotengine.org/en/latest/tutorials/step_by_step/instancing.html]Docs[/url][url=http://www.gamefromscratch.com/post/2015/02/23/Godot-Engine-Tutorial-Part-6-Multiple-Scenes-and-Global-Variables.aspx]Tutorial[/url]If you want to pass other specific parameters to your node just treat it like a class and add some functions for it where you can pass the data. Those new functions can be called in the parent scene and pass your data as an argument.

There might be better ways to do it but this is how I have done it and I'm quite happy with it:[code][...]subscene.set_pos(new_pos)add_child(subscene)[/code]I simply set the desired position before adding the instanced scene to the tree.

Thanks, guys! This is great information.Bryan

7 years later