So I have this value:
public int gold = 400;
That is located on another script.
I want, first of all, to get access to this value, which is not complicated. My problem is mostly that I need to do a function that will repair the hp of an object (a repair function) based on this value.
It will increment hp by 1 by frame (or more) up to full hp. But each "digit" restored must cost something, so I need to decrease the value of gold as long as this function is active.
I have no clue how to do that. I've been working on this for the last hours... Any suggestions? :S
NOTE : I code in c#.
asked Apr 25 '12 at 05:51 PM
For anything over time, think Update or coroutines. Each occurence of the event "I give 1 hp, but gimme the money mate !" you need to 1) check if there is enough gold 2) increase hp 3) deacrease the gold. It's probably going to look like that :
answered Apr 25 '12 at 06:28 PM