I faced a stack overflow problem in GDScript.
(Code to reproduce :)
extends Node
class_name MatchSession
func add_child(ch, un=true):
add_child(ch, un)
if get_child_count() == 2:
_start_match_session()
I faced a stack overflow problem in GDScript.
(Code to reproduce :)
extends Node
class_name MatchSession
func add_child(ch, un=true):
add_child(ch, un)
if get_child_count() == 2:
_start_match_session()
In your code, add_child
calls add_child
recursively, no stop condition:
func add_child(ch, un=true):
add_child(ch, un) # <--
if get_child_count() == 2:
_start_match_session()
Note also that Node.add_child
is not virtual. You are shadowing it. I suggest pick another name for your function.