where both test_projectile and mc_lk_projectile have a main node with the projectile_controller.gd script attached to them. If I remove one of the 2 preloads everything works normally. Otherwise the error appears on the second scene that is preloaded.
I changed from preload to load and it works now. I would like to use preload, but this seems way too broken and I have no idea what causes the issue. I’ve tried making a minimal project to reproduce the issue, but I’m unable to do so.
Not sure it’s exactly the issue faced by OP, but this kind of error can spring if two scenes reference each other, creating a cycling dependency issue on compiling, and a confusing error message.
From my understanding, when using preload, it tries to also preload every dependencies at the very same moment.
Using load() “fixes” that because it’s less likely to happen as it doesn’t require every dependency be loaded at the same time. But I believe it could still happen at runtime, just not when opening the project like now.
So when using Gdscript one should avoid circular dependencies altogether.
Hi, are you using this inside a singleton ? (An Autoload script)
If so this behaviour is “quite normal”, you shouldn’t use preload in autoload script because there will be a “race” of loading files and your program will try to load non referenced file or things like that. Or at least that’s what I understood when i faced this same error in the past.
It is not a singleton, but rather a script with some constant variables. I’m using it for keeping refereces to specific prefabs so I can spawn them during gameplay. I do similar thing for various resources like character actions (attacks, properties of the attacks, hurt/hitbox information). However I’ve since stopped using preload as it always had weird issues I couldn’t understand and just use load.
It is probably some cycling dependency issue as rphcos suggested. So I will just stick to loading everything instead of preloading.