0 votes

I am basically using 2 scenes at the moment:
- a "hub" where one thing you can do is create characters (just allocating stat points in fact)
- a "fight scene" where characters previously created are send to various missions

To save the characters "data" from one scene to another, I use an autoload to store the character ability values (name, level, power,..).

Basically when in the hub, creating a character will automatically add him with his stats to an Array.
When I want to move to the action scene, the variables (name, level, power...) of these characters are used to create a playable/movable character on the mission scene.

This side works fine for the moment. However after the mission is complete, when I use gettree().changescene() to move back to the hub, the data in the autoload are consistently replaced by "null" data.
The thing is when I am on the mission screen the only time I use the autoload is at the very beginning to create the playable characters for the mission (and I just use the values to set the playable character name or stats so they are not modified by this), but after that I never touch the data so I don't understand where and when the data stored in the autoload are being freed...

I have been reading various comments about weakref but I am having trouble really understanding it and from the bit I got, it wouldn't solve my issue as I don't need to check if the data have been freed or not as they shouldn't have been in the first place

This is probably not quite clear, but would anyone have a guess as to what it could be?

Godot version V3.2
in Engine by (12 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.