Can't change the transform of an instance

Godot Version

4.2

Question

I am trying to make a mirror reflect the laser that it collides with. I have managed to instantiate a new laser scene when it collides with a mirror but I can’t change the transform of this new instantiated scene. I straight up can’t access the transform property. The laser i have is a separate scene and the instantiating script is also attached to the parent node of this laser scene. I am using PackedScene. If what I am doing is wrong then what should I be doing instead.

if(collided_object is Node node)
{
if(node.IsInGroup(“Mirrors”) && laserReflected == false)
{
laserReflected = true;
var scene = GD.Load(“res://Laser.tscn”);
Node instance = scene.Instantiate();
AddChild(instance);
}
}

This is the code. If you need more information please let me know.
Thank you all in advance!

for this, i dont see your code actually alter the transform?

When I try to, I get this error:

“‘Node’ does not contain a definition for ‘Transform’ and no accessible extension method ‘Transform’ accepting a first argument of type ‘Node’ could be found (are you missing a using directive or an assembly reference?)”

is this 3d node?

Just Node. It is not 2D or 3D

You have to pass type Node2D, becouse default is Node.

try this
Node2D instance = scene.Instantiate<Node2D>();

I was working with a 3D game but it is the same thing. Thank you.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.