I’m wondering how reasoable working UDP protocol should be made.
To focus on something, let’s suppose that we have space-combat game. Up to 20-30 ships shoot at each other, plus we have some some ‘static’ stuff like meteors, space debris, space stations etc.
Everything should be computed on server - clients are not trusted (for computations/decision making, I’m skipping problem of aimbots here).
We have 6DOF. This means that ‘static’ object has 12 position properties (x,y,z,yaw,roll,pitch + the speeds for the same). By static I mean object that moves, but does not manuever (for example rotating meteor flying through space).
Static objects can be transmitted at very start of game + when they are created (for example dump missile probably will fit the bill). From this point on, they can be simulated on each machine, with only major events being transmitted (like collisions). On the other hand, they need to be acked from clients, so server will be sure that client knows about object.
Real problem is with maneuvering objects (spaceships, fire-and-forget rockets) plus with small projectiles (which probably fit ‘static’ object description, but there is just too many of them and they live for very short).
I suppose that for each active object, updated position+speeds have to be broadcast to everybody once per time slice. Probably there is also no need to ack packet every time - server will send updated version soon anyway. Client can make a prediction of movement between incoming packets.
[i]
-
How large should be a timeslice ? 100ms ? 500ms ? Does it make sense to have timeslice smaller than ping for any client ?
-
What is the best fragmentation of info ? Should separate packet be used for each object, or should as many active objects as possible be put into one packet ?
[/i]
I suppose that it would make sense to have different timeslices for active objects depending how far they are from given player. But I’m interested in solving problem of close objects - more distant will be just less frequent update of same algo.
Biggest problem for me is projectiles. I suppose that client would send packet with ‘projectile fire’ info to server, containing exact position/direction at time of fire - so they will fire exactly at position where client wants it, not depending on ‘self lag’ from server. Server would just check if it is legal (direction and position of fire is in contained between start and end positions for some window of past time) and simulate based on it. But how high-frequency projectiles should be handled ? Let’s suppose that there is a gun emitting 10 projectiles per second, each living for 3-4 seconds. This means that every client will produce around 30 moving objects. With 10 clients in close viccinity, it means 300 objects, 100 of them created and 100 of destroyed each second, with variable position and direction.
Info for such small objects could be simplified - they need just position (x,y,z) direction (a,b) and speed ahead (v) (plus maybe time of fire and maybe time to live) But this still means 6-8 parameters per object. Bullets from one player will have probably very small delta between shots, so probably positions could be compressed. But still this seems to be a lot of data.
3) Do anybody have any idea how to solve projectiles ? Will computing deltas and compressing them for every player be enough to trim amount of data to reasonable amount ?