Hi, I was wondering how I could implement an upgrade system for multiple characters. Each character would have its own upgrade page. Per say, the health script is used by all the characters, the health variable is public so naturally I changed the values on the prefabs themselves. Now, I’m not sure how I would connect that variable to upgrade.
I was thinking about calling the health script in the upgrade function, but i dont think it would affect the prefabs health.
The best way is to put all character information in a class or scriptable object then use that to create each individual character. Then call this Upgrade function only when the level up condition happends. Create a variable that will be the upgrade increment and add it to the health with
health += increment; An increment could also be done with health *= .1 so they gain 10 % health each level.
public void Upgrade()
{
health += increment;
// or
health *= increment;
}
this will only level up the character the script is currently on and will work for infinite levels.