Cyclic Dependency
Cyclic Dependencies, also referred to as “Circular Dependencies”, is a relation between two or more objects which either directly or indirectly depend on each other to function correctly.
The last game object references the first resulting in a closed-loop.
graph LR
Class_A --> Class_B
Class_B --> Class_C
Class_C --> Class_A
To spell out what is happening:
Class_A
depends on Class_B
Class_B
depends on Class_C
Class_C
depends on Class_A
In this case, the program or application throws an error as it does not know which class to initialize first.
To fix a Cyclic Dependency, simply ensure the dependencies of classes are not in a closed loop.
graph LR
Class_A --> Class_B
Class_B --> Class_C
In this case:
Class_A
depends on Class_B
Class_B
depends on Class_C
Class_C
does not depend on Class_A
Therefore the dependencies of the classes are in an open loop.
Resources
Github Project:
Godot Tutorials Resources