0 votes

Hi, I want to create a script in which when I am in the selected position, my door will open, and after leaving this area the door was closed, so I tried to do it using area2d, but when my character enters my area, I have an error like in title and someone can tell me how to fix it?


Texture green_line = (Texture)ResourceLoader.Load("res://Ship/Ship_Elements/Textures/greenLine.png");
Texture red_line = (Texture)ResourceLoader.Load("res://Ship/Ship_Elements/Textures/redLine.png");

private void _on_enter_area_body_entered(object body)
    CollisionShape2D line_collider = GetNode<CollisionShape2D>("StaticBody2D/CollisionShape2D");

    Sprite line = GetNode<Sprite>("Sprite");
    line.Texture = green_line;

    line_collider.Disabled = true;
in Engine by (75 points)

1 Answer

+1 vote

It seems like you are calling this from a different thread and the engine detects/complains when that happens.

see this page's "Scene Tree" section for how to use call_deferred() to do what you want.


by (220 points)
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.