Hello everybody !
I have a very weird problem in Godot.
I have two scripts : One is "Human.gd" and is a parent script to the second which is "Enemy.gd".
My parent script "Human.gd" has a signal "move_finished", which is emitted in a function called *"move*", which exist to move my KinematicBody2D from its actual position to a point given (in a smooth way).
Since it is not a teleportation, it takes time. Thus I need something to tell functions using "move" that they are arrived where they want. That something is my signal.
I use a yield to wait the signal.
This is what it looks like in the parent :
func move(point,tolerance):
var distance_to_go = position - point
distance_to_go = distance_to_go.abs()
var tolerance_v = Vector2(tolerance,tolerance)
var direction = get_orientation(point)
while distance_to_go > tolerance_v:
move_and_slide(direction * velocity)
animation(direction.round())
yield(self,"new_physics_frame")
distance_to_go = position - point
distance_to_go = distance_to_go.abs()
emit_signal("move_finished")
And the usage in the children :
move(path[i],0.01)
yield(self,"move_finished")
Now here's the problem (because everythig was too perfect) :
yield doesn't seem to retrieve the signal. Thus, my whole script is blocked in the yield part, and it never continue.
Someone has an explanation ?
Thanks in advance ! :)