A parent generates many mobs as children. The mobs want to get information about their surroundings from the parent.
Using get_parent() for this is bad practice, so instead, I've been using this elaborate combination of signals and callbacks:
Parent code:
var child = Child.instantiate()
child.connect("query_parent", _on_child_query_parent)
add_child(child)
func _on_child_query_parent(sender, question):
var answer = calculate(question)
sender.callback(answer)
Child code:
if wants_to_ask_question:
emit_signal("query_parent", self, question)
func callback(answer):
use_received_info(answer)
Are there any better or simpler ways for a child to get information from its parent?