Z
Z
Zimaell2020-08-07 12:09:27
Unity
Zimaell, 2020-08-07 12:09:27

How to set movement according to server time?

The idea is as follows - the coordinates of units' movement are calculated on the server, this data is sent to clients, then the client already "plays" the given scenario.
That is, if a player enters the game and there is already a battle going on, then units are placed for him based on the real time that was written in the script.
Example

index | date time | x,y,z
coordinates unit1 | 2020-08-07 15:00:00 | 0x0x0
unit1 | 2020-08-07 15:00:01 | 2x0x2
unit1 | 2020-08-07 15:00:02 | 4x0x2
unit1 | 2020-08-07 15:00:03 | 6x0x2


In the future, all calculations will be carried out on the server, in terms of who is targeting whom, who shoots at whom, how much damage it does, who was killed at a certain time. If a player makes any changes, a recalculation takes place on the server and is sent to all participants.

The question is, what is the best way to implement this? How to calculate the speed of movement?

I think to do this - every second is a checkpoint, roughly speaking every second is a segment from A to B.
But how to calculate the travel time? Indeed, in unity, the speed is calculated by Speed ​​* Time.deltaTime, how to calculate this speed exactly in seconds?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xmoonlight, 2020-08-07
@xmoonlight

Time synchronization needs to be done every n-microseconds on the server "heart-beat".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question