0 votes

Example I have main scene and I put draw line2d in another script with name 'Draw.cs' but nothing happen on screen when I call func. I got message 'Condition "!isinsidetree()" is true. Returned: get_transform()'

My func c#

public void Square_And_Line()
{

    var c = new Color(0, 0, 0, 1);
    var p1 = new Vector2(this.start_pos.x, this.start_pos.y);
    var p2 = new Vector2(p1.x, this.start_pos.y - this.img_height / 2);
    var p3 = new Vector2(this.start_pos.x + 96, this.start_pos.y - this.img_height / 2);
    var p4 = new Vector2(this.start_pos.x + 96, this.start_pos.y);

    var scene = (PackedScene)GD.Load("res://node_level1.tscn");
    var inst = scene.Instance();
    var l1 = (Line2D)inst.GetNode("line1");     
    var l2 = (Line2D)inst.GetNode("line2");
    var l3 = (Line2D)inst.GetNode("line3");

    l1.Width = 2;
    l2.Width = 2;
    l3.Width = 2;
    l1.AddPoint(p1);
    l1.AddPoint(p2);
    l2.AddPoint(p2);
    l2.AddPoint(p3);
    l3.AddPoint(p3);
    l3.AddPoint(p4);
}
in Engine by (16 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.