Theory, What should the server send back? (client-server)

Started by
4 comments, last by xsirxx 19 years, 7 months ago
Ok so say in a FPS client-server game, your clients send key strokes by bit flipping to the server. The server translates and calculates all the physics that act upon the object and changes the PlayerInfo. Now how should the other clients know? 1st: Should the server just tell the other clients that the person has hit this key? Thus just forwarding the information of small bits, and then gamestate updating every 1/10th of a second? 2nd: After server has recieve the keystrokes, calculate all info of the Player and query a SendAttitude of the player including position and new rotations and velocity? Then send out query to all clients? And still update gamestate? or drop gamestate updates? 3rd: Other ideas? --Brad
--X
Advertisement
Step 2 seems the best way to go.

You want to leave the client as just a dumb renderer. It sends the server any key input, you update everything server side, then you send back the information for the client to draw.
Yea essentially thats right. They both do the work load of physics but the server is always right when updating info. This is what I have implemented right now, but I didnt not test the other way...

Is this generally what people use when doing a fps, flight sim, action game?
-------Typo


--Brad
--X
thats basicaly how the HL engine does it, and others follow the same pattern.
Basicaly the client is given enuff infomation that it can work out a few frames if data gets lost on route, so you dont get laggyness of other players, however the server is always right and the clients arent trusted, so server does all hit scanning, performs its own physics based on input etc and the client just runs its own sim when needed.

Things like reload, weapon changes and firing animations ARE done on the client, again to reduce apprent lag (earlier CS netcode used to send the fire confirmation to the server and not play animations etc until it got a message back) but ofcourse the server has to be told of these.

So, basicaly from the server pov its

- read all game data from clients
- update game states
- send new data back to clients

From a clients pov its

- send data to server
- if we have new data then update game state to sync with server
- else carry on sim based on last known infomation

Ofcourse, the sim will drift out if lots of packet loss accure, but thats unavoidable.
You could send enough data per n/seconds so that the client will be able to predict the actions until the next update.

If its 30/sec, and the server receieves input that a client just changed direction, is that client going to move so far it'll be noticable when the server updates everyone else 1/30th of a second later?
Roger that, lets run like hell!
This all is very good, but when the server sends back the information what happens? Say for instane it is a time based game, should the server send time stamped information? Then subtract the time from the physics routines?
(I have it so I update the angle, velocity, and pos so it is never that far off when I run my physics.)

Also, there is talk about interpolation? and cubic splines... Are these things to consider on a FPS? How much will they effect the game?

--Brad
--X

This topic is closed to new replies.

Advertisement