T
T
Tamaz Kharlamov2017-09-03 10:54:58
Programming
Tamaz Kharlamov, 2017-09-03 10:54:58

How is character movement control implemented on the server or on the client?

Interested in the following. Let's say we have a coordinate grid. 10 by 10 There is a wall in the middle. What controls whether the character can walk on this place or not. Server or client? If the server. It's a little unclear to me how exactly to implement this. My fantasy is only enough to write down all the coordinates where the character cannot pass. But this will consume a lot of resources. calculation of all movements of the character. Not to mention that if there are a lot of them. And the map will not be 10 by 10. If possible, then indicate the literature that covers this.

Answer the question

In order to leave comments, you need to log in

8 answer(s)
A
Anvar Shakhmaev, 2017-09-03
@RxR

Movement (change of coordinates), as well as other logic that changes the state of an object - on the server. Rendering on the client, interpolation is used to smooth actions. Read about interpolation, extrapolation, lag smoothing.
Play cs1.6 and notice that your character will not move when disconnected.
https://habrahabr.ru/post/328702/
https://habrahabr.ru/company/mailru/blog/220359/

A
Alexey, 2017-09-03
@AlexMaxTM

Control should always be performed only on the server side! Any client can be hacked (although sometimes the server too). Only the server sends the object to the client, its characteristics, its current coordinates, its freedom of movement relative to the reference point. The client only displays what the server sent him.

A
a0lwq, 2017-09-03
@a0lwq

Client - faster.
Server - protection against cheaters.
It all depends on how stupid / lazy / whether the developers have the resources of time / money.
A good system checks 2 times:
On the client - to quickly redraw.
Then on the server - for control.
Then, having received confirmation from the server, the client redraws in the right place again.

V
Vitaly Stolyarov, 2017-09-03
@Ni55aN

How is character movement control implemented on the server or on the client?

On the client, calculate movements on each frame (for example, with VSync it will be every 16 ms), and on the server it will be calculated on each request (let, if with WebSockets, it will be approximately every 100 ms) and synchronize on the client. The main thing is that the reliable position is determined on the server by calculating the acceleration and direction transmitted from the client (or other parameters, depending on the specifics of the game), and the client transmits the received position
There are 2 options:
1. The scene will consist of a strict grid (as in Bomberman), then information about objects can be stored as a two-dimensional array (for a 10x10 scene), this will take 100 elements, and it will be easy to check for collision. If, for example, the character is at (8, 3) and wants to go to the right, then you need to check if there is an object at position (9, 3)
2. Use primitives (lines, polygons, circles) to describe the scene in real coordinates. Here it is more difficult. It is worth using libraries such as Box2D

I
Ivan Vorobei, 2017-09-03
@ivanvorobei

Again, a huge callback. The implementation must consider both the server and the client. But the wall must be implemented on the client. But to store its characteristics - on the server.
If a grid with characteristics (wall) was loaded from the server, then there is no problem on the client not to let it pass

A
Artyom Egorov, 2017-09-03
@egoroof

And there and there to do a check and periodically synchronize. In case of a conflict between the server and the client, take the result of the server (since the position can be faked on the client side). If you played WoW, it can be clearly seen with lags - you did something, it seemed to you on the screen, and when the lag disappeared, everything that was done was rolled back as if you had not done it.
According to the literature here you can read anything on the topic of multiplayer online games.

O
OnYourLips, 2017-09-03
@OnYourLips

But this will consume a lot of resources. calculation of all movements of the character.
The server has more simplified calculations, the figures are less detailed.
There is a very good series of articles on this topic from Blizzard about their implementation of Overwatch.

4
4iloveg, 2017-09-03
@4iloveg

Not only that, the server must check the availability of coordinates to move to them. But also the speed with which a person moves. The same WOW on pirates - cheats allowed you to fly all over the map at a speed 100 times higher than normal + much more.
So if you are doing a serious project, then as written above - only the frontend is on the client, all the logic is only on the server

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question