|Topic was automatically imported from the old Question2Answer platform.
My problem is as follows:
- I create enemies using an abstract enemy class and instancing it
- I read files from a “user://whatever” that has .tres files in it
- I have an initiating function in the abstract enemy scene that attaches the .tres file into the variables of the enemy
- I pack this instanced scene with the .tres file into a new scene
- I save that scene somewhere
- I create an .instance() of that packed scene,but the variables are null
Im doing this method because I want to create .tres files and instantly add new enemies,and also load them on the loading screen so there are no freezes during gameplay,but this doesn’t seem to be working.
Anyone with a similar problem?
Make sure to export the variables that need to be saved.
Also, the variable initialized on _ready() need to wait for the Node to be added to the tree.
The .tres file has some instructions on how to make the enemy perform certain attacks,and add animations to them again from “user://”
Basically it instructions to create raycasts with certain parameters,and add them on a node, and add animation files with functions.
The other variables (such as hp/speed/etc) work fine,but this part doesn’t
I feel like whatever the scene is,if you pack it,it should remain the same and be “saved” as a scene/node to be instanced of,and not require you to export every variable,otherwise it seems somewhat counter-intuitive to what its purpose it. I do not know enough about the engine to understand if this is doable,but right now I don’t see any other reason to use packed scenes.
Zaxrem | 2021-01-01 17:34