I’m working on an iOS game, and I’m wondering what the best way to create real time delay would be, something like the build delays in TinyTowers or other similar games.
I’m assuming it’s probably easiest to get the system time and adding the delay, then checking back to see if the time is greater than the delayed time, however, I’m sure most people will just change the time settings on their iOS device to cheat. Any ideas would be great.
Yeah same way they do it in the FPS tutorial. Set a time when you build
if(bTime + offSet < Time.time)
BuildTheTower(); Good Luck!
thanks Cat_Ninja. I’ll try that.
just out of curiosity, if a person leaves the iOS app, does this nullifies the time?
I don’t know much about iOS development but I’m pretty sure Time.time is started when Unity is started, and I’m not sure what you’re asking. Like would it work as a clock?
Hi Cat, thanks for the reply. I think you’re right, Time.time only runs when Unity runs. Originally i was going to use System.dateTime, and save the offset build time in prefs, so that if the user quits and comes back to their game, it would seem like it’s continuous. The issue here is that people might cheat, and change their system clock time to speed up their build time. I was planning on selling little power up type things as an in-app purchase to speed up the build time. I’m trying to figure out what other people would do to limit cheating through time… Thanks.
Only thing you could do is force authentication through a third party service (e.g. have a server that gives time on client request). Anything less than that is hackable.
Ok. Thanks NPSF300.
Can’t you use yield WaitForSeconds(X) for this?
Yeild WaitForSeconds(x) would only work while the game is running though. When the user quits the app, the time resets. I want them to wait a few hours.
Ah sorry, I must have misread the question. I shouldn’t post at quarter to five in the morning!
I think your best bet is connecting to a server to get the time, if that is the case. Failing that, could you not have a very small app that constantly runs independently of your program, that simply just ticks over?