currentWeaponConfig

When we load the game restorestate equips the weaponconfig. But in awake we set currentWeaponConfig to defaultweapon. I forgott, does awake happen after or before restore state? It works so player has the saved weapon in hand.

You can test this yourself with some simple Debugsā€¦

Add these Debugs to the Awake() and RestoreState() methods:

Debug.Log($"{name} Awake()");

and

Debug.Log($"{name} RestoreState()");
Or click here for the answer

Did you try it?

The answer will be yes, Awake() is called before RestoreState();

Yes thank you!

As a bit of followup, OnEnable() and Start() will be called after RestoreState.

ok thank you. Does onenable get called before or after start?

OnEnable() is always called before Start().

Constructor -- we don't deal with that
Awake(); //only called once
RestoreState(); //only called by Load() once
OnEnable(); //called when object enabled, can be called multiple times if object is disabled/enabled, etc
Start();  //Only called once
Update(); //Called every frame
LateUpdate(); //Called at end of frame cycle, used for camera positioning mainly
FixedUpdate(); //Physics, called at regular intervals
OnDisable(); //Called when component or GameObject disabled. 
OnDestroy(); //Called when component or GameObject is destroyed.

great thank you :slight_smile:

Privacy & Terms