0 votes

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?

in Engine by (12 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.