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?

Script

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;
}
asked Jan 12 in Projects by daniel500013 (54 points)

1 Answer

0 votes

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.

https://docs.godotengine.org/en/3.1/tutorials/threads/thread_safe_apis.html#scene-tree

answered Jan 13 by Jason Swearingen (206 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 How to use this Q&A? before posting your first questions.