Hello all,
I am working in a project with Godot. The thing is that I have three scenes that are very similar between them. Basically, they have the same node structure, and mostly the same content in the scripts. So I decided to create a class: particle_class.gd
, which extends RigidBody
.
Then, the three scenes (which are RigidBodies) have a script attached, that extends particle_class.gd
. Until this point, everything is fine.
But now, I want to make an instance of the children scenes. Then, inside particle_class.gd
, I have something like:
var particle = preload("../scenes/free_particle.tscn")
func do_things():
var aux = particle.instance()
add_child(aux)
When I try to compile this, I get this cyclic preload error:
Parser Error: Script not fully loaded (cyclic preload?): res://scripts/particle_class.gd
I imagine that this is coming from the fact that when I load free_particle.tscn
, this tries to extends particle_class.gd
, which iteratively tries to load again the free_particle
scene.
My question is: how to avoid the cyclic preload error?