- Home /
Upgrade system with multiple characters
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.
Would I call the gameobject?
Please help <3
Thanks in advance.
Answer by melsy · Feb 03, 2018 at 02:22 AM
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.
use something like this for all attributes .
I have a health script which is used for all the characters. I want the upgrade system to be for individual characters.
this will be for individual character. The call only only go to the character you send it to.