I’m having a recent issue involving turret-behavior objects.
In my game, there’s a saving system that saves the position and the values of their internal variables into a key in a dictionary. During the loading of these objects, the system creates the objects and loads the state via JSON.
After saving, closing the game, and opening it again, the turrets are loaded but do not work. I’ve tried making them target again, but it didn’t work.
I realized the problem lies in the action: set from JSON.
How did I find this out? I created a template to demonstrate how the problem occurs.
In this template, you can add turrets by simply clicking on the orange area. Once created, the turrets will automatically aim and shoot at the red enemy.
You can save the position of all turrets by clicking save, and load them after closing the game and reopening it. The game will automatically load the turrets if there is a save.
The issue I mentioned above also happens in this template. After saving, closing the game, and reopening it, the turrets are loaded and positioned correctly, but they don’t shoot. However, after a few seconds, they start functioning normally, which doesn’t happen in my game.
Does anyone know what might be happening? Could the 'set from JSON' action take too long to load, and during this loading, it deactivates the turret behavior?
template:
drive.google.com/file/d/1YZw0eo2uilxNvL7Mvh8Ikv3w9NqxuR-_/view