Checkpoint Saving correctly but not Loading

I ran into another loading issue… upon setting up the Save and Load in Transition, Saving is working correctly (I can test it by loading the saved checkpoint with the load Key Binding), but when I go back to the previous scene… none of the enemies are dead.
However, if I kill a couple enemies, hit the save key binding, reloading the scene from the editor, and hitting the load Key binding… the enemies are dead… SO it is saving the information… its just not loading correctly.

My transisiton method

private IEnumerator Transition()
        {
            if (sceneToLoad < 0)
            {
                Debug.LogError("This portal is not linked to a valid scene");
                yield break;
            }

            DontDestroyOnLoad(gameObject);

            int _currentHealth = GameObject.FindWithTag("Player").GetComponent<PlayerControl>().GetCurrentHealth();

            fader = GameObject.FindObjectOfType<Fader>();
            Fade();

            yield return new WaitForSeconds(fadeDelay);

            SavingWrapper wrapper = FindObjectOfType<SavingWrapper>();
            wrapper.Save();

            yield return SceneManager.LoadSceneAsync(sceneToLoad);

            wrapper.Load();

            yield return new WaitForSeconds(fadeDelay);

            Portal otherPortal = GetOtherPortal();
            if (otherPortal == null)
            { Debug.LogError("Other Portal not Set"); }
            UpdatePlayer(otherPortal, _currentHealth);
            
            Fade();

            Destroy(gameObject);
        }

my savingWrapper

    {
        const string defaultSaveFile = "save";

        private void Update()
        {
            if(Input.GetKeyDown(KeyCode.F5))
            {
                Save();
            }

            if(Input.GetKeyDown(KeyCode.F6))
            {
                Load();
            }
        }

        public void Save()
        {
            GetComponent<SavingSystem>().Save(defaultSaveFile);
        }

        public void Load()
        {
            GetComponent<SavingSystem>().Load(defaultSaveFile);
        }



    }

My Saving system calls for Health…

 public object CaptureState()
        {
            return currentHealth;
        }

        public void RestoreState(object state)
        {
            currentHealth = (int)state;

        }

I have solved the issue, it was actually an issue with how my Health component was assigning the current health, and was getting overridden. I rearranged some calls, and the checkpoint system is working. (I even added a second “Checkpoint” save, that is separate from the main save! :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms