Hello.
There are Area2D (EnemySpawner scene) to which the script is attached:
extends Area2D
export(Vector2) var spawn_position
func _on_EnemySpawner_body_entered(body):
if body.name == "Player":
var enemy = load("res://Scenes/Enemy.tscn").instance() # Enemy - KinematicBody2D
enemy.position = spawn_position $"../../Enemies".add_child(enemy) # It gives errors
and the main scene in which there is an instance of EnemySpawner.
And so, at the entrance of the player in the region, the enemy will spawn, but issues:
body_set_shape_disabled: Can't change this state while flushing queries. Use call_deferred() or set_deferred() to change monitoring state instead.
body_set_shape_as_one_way_collision: Can't change this state while flushing queries. Use call_deferred() or set_deferred() to change monitoring state instead.
body_set_shape_as_one_way_collision: Can't change this state while flushing queries. Use call_deferred() or set_deferred() to change monitoring state instead.
What am I doing wrong?
It is translated by Google, inaccuracies are possible.