I'm new to Godot and while building my first game, i'm coming across one problem.
As a first project, i'm building a temple-run like game, where my world is generated while the player proceeds. New parts are generated and old parts are deleted.
Some of these parts contain area nodes which are assigned to the group obstacle
.
In my player scene, i want to connect to all of these area nodes body_entered
signal.
What i tried is:
func _physics_process(delta):
for obstacle in get_tree().get_nodes_in_group("obstacle"):
obstacle.connect("body_entered", self, "_entered_obstacle")
But this results in an Error:
ERROR: connect: Signal 'body_entered' is already connected to given method '_entered_obstacle' in that object.
And the function _entered_obstacle
is never triggered.
What is the best way to do this?