There are a couple of issues with this line:
tilemap_movement.disconnect("movement_finished", _on_movement_to_exit_complete(character))
Firstly, you're using the old Godot 3 API. You'll want to do this instead:
tilemap_movement.movement_finished.disconnect(_on_movement_to_exit_complete(character))
Secondly, the fact that you have parameterized anonymous functions as listeners makes things a little tricky. Let's say you call signal.connect()
and pass a parameterized listener. Later, when you call signal.disconnect()
, you have to pass it the same function. Calling _on_movement_exit_complete()
with the same arguments returns a different (identical) function. There are a couple of ways you can work around this. A common solution would be to store your own references to the listeners for later use. something like this:
var movement_listeners = {}
func some_func_where_you_add_listeners():
var character = # IDK, some reference to a character
var listener = _on_movement_to_exit_complete(character)
tilemap_movement.movement_finished.connect(listener)
movement_listeners[character.name] = listener
func _on_movement_to_exit_complete(character: Node2D):
var f = func():
# ...
if party.get_child_count() == 0:
for party_member in initial_party.get_children():
# ....
var listener = movement_listeners[character.name]
tilemap_movement.movement_finished.disconnect(listener)
movement_listeners.erase(character.name)
load_next_level()
return f
I hope that makes some sense
There isn't a signal because PathFollow3D doesn't do anything on its own to move a Node. It just finds a point on the parent Path3D based on it's
progress
/progress_ratio
value.I would suggest wherever you are updating the PathFollow3D's progress, add a check for: