I am trying to implement an energy system same as in Injustice 2 where if user uses some (amount) energy to play a level the timer should start and after every cool down time it should award 1 energy to the user. Problem I am facing is I am not able to figure out a way to save new timestamp to same variable after every energy increment iteration. Any help/guidance on how to tackle this problem is appreciated. Thanks in advance.
PS: I haven’t worked with DateTime before, this is the first time.
Hi, Thanks for replying. I suppose you’re saying to use DateTime.Now.AddMinutes. It’s a good idea but I want to save new TimeStamp (DateTime.Now.Ticks) to playerprefs everytime 1 energy is added and use that timestamp to check if cool down has ended for new energy to add and repeat above steps. Saving TimeStamp to playerprefs is important.
I will also give AddMinutes a try and find a way to use it in my case.
This is because my project is on Android and the energy system should also work when the game is off. If there’s other way to achieve this please let me know.
Hi,
I tried this way, you can see the code. Is there any way I can repeat SetTimeStamp() and EnergyTimer() every energyRefillTime i.e. 10 seconds for now?