[Anet] client side prediction

Posted By: darkinferno

[Anet] client side prediction - 10/29/09 13:56

currently i do movement on the server which works fine, downfall is, the clients dont see their movement until the roundtrip to and from the server, what i want is some advice on predicting local movements.

my idea so far is to let the client be able to move locally and updates it position to the movement received from the server, this works but as can tell there is a jump most times as the local movement is snapped to the position received from the server...

any ideas on implementing this update smoothly?
Posted By: Dark_samurai

Re: [Anet] client side prediction - 10/29/09 14:25

you could interpolate to give it i smoother look (of course this doesn't solve the problem completly, but it will look much better).

You should think about why the movement of the server is so different to the movement of the client and try to minimize that problem (more updates, better prediction, ...)
Posted By: Gumby22don

Re: [Anet] client side prediction - 10/29/09 23:01

also think about letting the server calculate the one-trip lag from the client, and re-calculate that last segment of movement with the input included (ensuring legality). This might drop some of your difference in server and client-side effective movement.

Don
have a great day
Posted By: Damocles_

Re: [Anet] client side prediction - 11/01/09 18:55

Make the player move directly on the client,
and send it position to the server.
Only show the other bots/players according to their servestate.

Thats the way Unreal Tounament and WoW work for example.

Take the clients position as direct data for the server,
thats the simplest way.
The server then does not move the entity, but takes
the clients send postion as actual serverposition.

You could also let the client calculate directly how another
player was hit by a weapon. But doing the movement locally
is more important.
Posted By: Dark_samurai

Re: [Anet] client side prediction - 11/02/09 08:47

I wonder why Ureal and WoW did it that way... Isn't that totally insecure (speedhack, aimbot, ...) or do they have security checks on the server like controling the maximum speed?
Posted By: darkinferno

Re: [Anet] client side prediction - 11/02/09 09:17

am also curious to why you think Unreal and WoW did that, i knwo speed checks work but i guess there are work arounds
Posted By: Germanunkol

Re: [Anet] client side prediction - 11/02/09 09:42

I'd go for both client and serverside movement. the serverside movement should depend on the keystates on the client, and, if you're good, calculate the ping into it somehow. then the position should be sent back to the client who then checks how different the server side movement was. Shooting is more complicated, you once sent me the link where they explained how css did it, with the server using the ping to calculate if the trace the client sends out would have hit something if the sending of packets were instant. I'd attempt to go for that method, if you want to make it real accurate, even though it's a pain: you'll have to remember the positions of the players during the past second or so to make sure all clients have an equal chance of hitting something, even when their shot arrives late on the server.

as for movement: send keystates from client to server and let both calculate the movement. then send back the positions from the server to all clients. let the client who's playing the character check if his movement was correct, and let all other clients simply interpolate and predict what position will be next, depending either on the last positions or on the keystates that the client sends. The animations I'd do entirely locally, I don't think you'd even need to send animation states or types, instead check in what direction the player moved during the last frame and play the corresponding animation.

Just my idea.
Good luck.
Posted By: Damocles_

Re: [Anet] client side prediction - 11/02/09 13:13

Wow and Unreal (also Quake World) did this client side calculation for a good reason:
Playerexperience in Internet play.
(Test it yourself: when playing WoW, take out the
LAN cable. You can still walk freely with your
player for some seconds. Its clearly calculated on
the client)

While a LAN game can be handeled fully on the server,
it does not work in the Internet.
The worst is to have a lag in players own movement + rotation.
This would make the best game not enjoyable.

(RTS games for example can work fully server side, as the
Lag in unitmovements is not experienced in first person)


Unreal Tournament for example does a serversimulation of the movements,
given the keystrokes, positionas and velocities of the
clientmovement. If there are diviations,
the server will kick back the client to
it "simulated" correct position.
Its important that client and server
have agreed on a syncronized gametime.
For you (hobby game) you can skip the server check,
as cheating is not really an issue, and the serverside
clientsimulation is quite complex.

Other actions like shooting can be handeled in a clasic way
by the server. You will notice in UnrealTournament, that
the bullets are shot with an offset in high latency games.
So the shooting is actually done on the server, triggered
by the client input.
But movement+rotation should be done locally on the server.

A problem can be collisions between players.
Quake World solved that by using a prediction algorythm, based
on the position + velocity of the bots/actors.
KInd of having an additional collision hull interpolated
in front of the players movement direction for
bot to bot collisions.
Wow solved that, well : by having no player to player
collitions at all.

Posted By: darkinferno

Re: [Anet] client side prediction - 11/02/09 13:29

i dont think they are doing fully client side movement, i think they do as we were suggesting, move on client and on server, the server is king, so every few seconds or so, an update is sent to the client to set him to what the server sees, if i were to plug out the lan cable, i'd still be able to run around the entire map but the server character wouldnt move at all
Posted By: Damocles_

Re: [Anet] client side prediction - 11/02/09 13:41

But the short term movement is done by the client.
The server is a mere control instance, to adjust
for object-interactions that the client can not predict,
and inaccuracies (by cheating or timeoffsets)

In your game you can assume that there is not cheating,
making the whole development easier.

But it is definitely not done in the classic way:
-client does an input/keystroke
-server receives it, moves the player
-server send it to the client
-client receives it and updates/interpolates position

That would play awfull in a first person game.

---

ANother thing:
by having a full server side movement, you
would allways give the full advantage to the server hosting
player. He would be the only one who could do lag-free
accurate and quick movements, making the game unfair
by stucture.
© 2024 lite-C Forums