Hey community! I am making a clicker game for android (Similar to cookie clicker). In the game you tap the screen and it registers as 1 click. There are buildings that I can buy that automatically click. Its simple code, really. What I am trying to figure out however is when the player exits the game, I want to record the date and time then when they reopen it check the date and time again, do some math to find out how much time has passed then add all the clicks the buildings would have generated. Any Idea how I can do this? I think there is some date/time code, but I have never used it so I don’t exactly know the calculations I would have to go through for that. Thanks all!
ok so first u have to get the current time, import system into your script then save the current time to playerprefs or smth, you can choose that. if its a clicker game I highly recommend not doing playerprefs but if it is completely offline then it rly doesn’t matter… but anyways just save DateTime.Now
into ur playerprefs with any name. now in start function you should save another DateTime.Now
into some variable… i’ll call it a, and set another variable to the playerprefs datetime, i’ll call it b… then just do newvariable = a - b;
, that will give u the time that has passed since they last played, and now with that um I guess you would convert that time into seconds somehow, there might be some code for that… then just do a for loop that gives u x points for each second, hope it helps!! I have nvr actually done this b4 it is all just guesswork it may be completely different and if it is then sry bout that… but I rly hope it helps!
1 problem with that however… the plaer can simply change their phone time and the game wont rly notice :o does anyone know a way to get the time from time.gov instead? that way it is impossible to cheat! pls some1??