Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | piet |
I instance a scene (type node with child mesh) from a script with the following code:
var scene = GD.Load<PackedScene>("res://assets/scenes/plane.tscn");
var node1 = scene.Instance();
node1.SetName("node1");
AddChild(node1);
The node is displayed in the game. Now I want to move it to another position to finally build a complete level by script. How can I set a position for the node? Do I have to use another type?
Answering my own question before approval:
Change the position of the mesh (at position 0 in nodetree) as follows:
node1.GetChild<Spatial>(0).SetTranslation(new Vector3(0,0,1));
Is this the right approach?