#Preloading fail

6 messages · Page 1 of 1 (latest)

glossy cypress
#

I am preloading a resource in multiple nodes. However, when I use the same code in the Main node (top-most node in the scene), I receive Parse error: Could not preload resource file.

The code:
@export var turn: Turn = preload("res://Common/Turn.tres")

If I remove that code from main.gd, then everything works again. However, that same code works if I put it in another node.

Can anyone help?

sudden crane
#

Could be a cyclic reference thing where you are trying to load something that has a reference to the place you are loading it from

#

One possible workaround in this case would be to load() at runtime, in _ready() for example

#

You could still use an export var but with the file_path instead

glossy cypress
#

Thanks for the answer. I will try loading on runtime. Also, do you mind giving a brief example of what you mean by file_path? Did I not use file_path in my code?

sudden crane