Player stays dead after loading

I had a bug(?) when, if player lost all health and I loaded save when he was still alive, the character would be uncontrollable and stayed “dead” on the floor. I modified my load method in health script a bit, and it works fine now.

public void RestoreState(object state)
        {
            health = (float)state;
            
            if (health > 0)
            {
                isDead = false;
                GetComponent<Animator>().SetTrigger("load");

            }
            else Die();
        }

trigger “load” is connected from “any state” to “locomotion” without exit time

Well done.
As the course progresses, there will be a few other “state” issues that are caused by us not truly reloading the scene with the “L)” key. In the last course, we will be implementing a Menu system where rather than L)oading with a key, you’ll exit and restart the game proper, which will load the game from a pristine state.

Oh, i see. will loading from “scene 1” to “scene 2” also be fixed with that?

Correct, when transitioning between scenes, the new scene starts in a default state, so RestoreStates will function correction without “zombies”

Privacy & Terms