I’m making a turn-based battle game, where you run around an overworld map until you get into a random battle and then you’re teleported to the battle scene. Basic old school rpg stuff. At certain points in the game, your character learns new magic abilities or can equip new gear so they are added to a list that I keep on a GameManager object. My problem is that when I stop running the game, the prefabs keep all the stuff that I acquired while testing the game. An example, they start with no gear on so the list is empty, but once I equip gear and then end the test run, the gear stays on the list and I have to manually remove it in the editor. Why is it changing the prefab instead of the instance of the prefab? I don’t know if it’s relevant, but whenever I start a battle, I instantiate the players with hp/mp values that I saved in my GameMgr from the last time I finished a battle.
edit: added some code to maybe help find the problem
So this is the code that Instantiates the player
for (int i = 0; i < GameMgr.instance.herosInParty.Count; i++) {
GameObject newHero = Instantiate(GameMgr.instance.herosInParty_, heroSpawnPoints*.position, Quaternion.identity) as GameObject;*_
newHero.transform.Rotate(0, -90, 0);
newHero.name = newHero.GetComponent().hero.baseName;
herosInBattle.Add(newHero);
}
This is an example of something that gets changed during runtime and doesn’t get reset to default after ending
for (int i = 0; i < player.hero.equippedGear.Count; i++) {
//if gear slot matches, remove old gear, add new gear
if (Inventory.instance.GetItem(player.hero.equippedGear*.itemID).gearSlot == item.gearSlot) {*
player.hero.equippedGear.Remove(player.hero.equippedGear*);*
player.hero.equippedGear.Add(item);
gearSlotPanel.transform.GetChild(1).GetComponent().text = item.name;
player.hero.currDEF = def;
break;
//if gear doesn’t match, check for another iteration, add gear on last iteration
} else {
if (i < player.hero.equippedGear.Count - 1) {
continue;
} else {
player.hero.equippedGear.Add(item);
gearSlotPanel.transform.GetChild(1).GetComponent().text = item.name;
player.hero.currDEF = def;
break;
}
}
I was looking at writing a method that will initialize all the values to their default values when you run the game, it’s just a lot of values to set and I’d have to write it for the four different characters.