Godot V4.1
The child of something I want to clone is having troubles accessing functions of the parent.
when I try to run my code, I get [Invalid call. Nonexistent function ‘initialize_life’ in base ‘Node2D’.]
Here is the part of the code responsible for cloning
food = roundf(food / 2)
var thing_scene = preload("res://Thing.tscn")
var parent_position = position
# Clone Variable prep
var thing = thing_scene.instantiate()
thing.position = parent_position + Vector2(randf_range(-50, 50), randf_range(-50, 50))
get_parent().add_child(thing)
thing.initialize_life(DNA.duplicate(), food) # Call initialize_life explicitly
and here is the function it’s having troubles running.
func initialize_life(DNA, food):
# I left out defining variables because it seems irrelevant
var RNA = [DNA, speed, size, storage, SplitPower, hunger, MutationRate, neurons]
if is_inside_tree():
Pause(RNA, food)
else:
call_deferred("Pause", RNA, food)
The pause func just leds to a get_tree().create_timer(1).timeout.