Bug with loading

Some lectures ago I noticed that a bug had been introduced, but I don’t know when it happened and if it was something that I broke. To reproduce it I did the following:

  • save
  • kill a guy
  • load
  • the guy should be alive again but instead he was dead
  • my max health and my level were not correct, they should be at the saved state but they were increased
  • if I stopped the game and started again it was fine, all states were set correctly

I don’t know if it is addressed later in the course and even if anyone else has it, but I added the following code in my SavingWrapper in the Load() method and it seems fixed now:

        public void Load()
        {
            GetComponent<SavingSystem>().Load(defaultSaveFile);
            StartCoroutine(LoadLastScene()); // ADD THIS
        }
1 Like

This might cause quite a problem when you switch to another scene.

Might I suggest an alternate solution:

Remove the line you added to Load.
Go to the Update function and find if statement that calls Load();
Change the contents from Load() to

StartCoroutine(LoadLastScene());

This will solve the issue of the characters not coming back to life, and avoid breaking the Portal process.

1 Like

Thanks a lot, indeed going to another scene was broken and your suggestion worked fine :slightly_smiling_face:

I didn’t notice this bug before this post.
But I have it also, so you save the day again.

Thank you much Brian,.

Thank you for sharing this with us.

Privacy & Terms