Not using strings in Saving Weapon of choice

Hi, Sam is proposing to use strings to make serializing weapons possible
obraz

I think better way is to load current weapon from Resources folder in EquipWeapon method like that

And then when method is called use the gameObject.name as a parameter
obraz

Then we don’t need Serialize Field for string defaultWeaponName and we use defaultWeapon Weapon refernce like before.

Thoughts?

Once the implementation of saving the equipped weapon is completed, there is no need for the defaultWeaponName field anymore, anyway :wink:

in Start() you just check if there is a currentWeapon set (which happens in RestoreState()) and if there’s none, the game is started for the first time and there was no save file to restore the last equipped weapon from so we grab the defaultWeapon.

(in my project, when I start the game it still runs Fighter.Start() before the save is restored, but since it is reliably loaded from the save file afterwards, that’s fine…)

Privacy & Terms