D
D
Deman12020-02-17 03:10:59
C++ / C#
Deman1, 2020-02-17 03:10:59

How to create a timer system?

Hello, tell me how to create a timer system that will work even when the game is turned off, this is often used in games, for example, to restore energy or something else, I will be very happy if you throw an example or demo because I didn’t find it on the Internet, but otherwise I would have a basic part of this function, I didn’t find anything about it in the internet.
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
X
xmoonlight, 2020-02-17
@xmoonlight

At startup, a request to your server and checking the elapsed time for a specific game indicator, and more - nothing at all (otherwise everything will be replaced)!
See the UnityWebRequest doc .

G
Griboks, 2020-02-17
@Griboks

Can't agree with xmoonlight . If you don't care about being able to hack your game, then every time you use (not start) check the elapsed time. There is no timer, it's just an appearance, the elapsed time is actually calculated on demand.
If you don't want your game to be hacked, then you send all the player's actions to the server, and the server itself checks everything (as described above), runs the action, and returns the result. In this approach, encryption is not necessary; The game client acts as a "screen" to which the server streams interface changes.
Example: you want to buy something. You press a button, the game tells the server that you pressed the button. The server checks which button you pressed, if you have enough gold, makes the purchase, adds it to your inventory, and sends back the new amount of gold, new inventory content, and new UI art. Physically, game resources are stored on the client, but their display is controlled by the server.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question