   Send data for fast action game
  Hi all, my game is a fast action game, fast becouse players can fire a lot of bullet and can it fast!Im using UDP protocol, what's the best way to send data whit this kind of game?My data packet is 130 byte so if i send it every game cycle i occupies a lot of bandwidth, but if i send it whit pause(each 50 ms) i have a bad effect, player can see another player in position where there isn't!!!So, in this case, waht is the best way?Think a game like quake3.   
  My major problem is send fire action! A fire action is specified from:1) kind of weapons thta fire the bullet.2) direction where bullet is fired.3) speed of player to adding at bullet speed when it's fired.To send this data i have to send a lot of bit and a player can fire a lot of bullet for second, so...ps. to add a random effect at bullet fired i have to send the random multiplyer too!   ;  Im think that im in a wrong way!Now im using server-client system but im use server only to send data at all clients, and not for process game data, so:CLIENT1 send data at SERVER,SERVER receive data and send it at all clientCLIENT2,3,4 receive data from server and process it.In my game there are a lot physics, all object and player are in a physics world, so when a player fire a bullet is inputted in this world.Each client have a copy of this world whit same physics laws so if i add a bullet in my world and in the world of other client im pretty sure that bullet take same position.So to send fire action i think there aren't particular problem...But if i send player position only each 50 ms(20 send per second) each client can rendering other client only at 20 fps...it's very small, i can see a player in a wrong position... How i can resolve this?Player are process from physics laws to(in according whit key press) but i think if i send only keys press, client can process a wrong position of other clients.If i send keys press whit player speed and player pos i think to have wrong position too...   ;  ok i want to point out a few things:first of all: let the server do the physics.clients should not be bothered with physics of things they cannot see.and: even if you have the same formulas on all clients, calculations can be different and your game can go out of sync. may be not in the first minute, but since all clients have different pings, it can happen.then, udp is fine for games, tcp is also fine for games. take what you like better.tcp-packets always reach the destination. therefore, you can send only the changes since the last update.udp-packets reach the destination with all data correct, or they dont reach it.this is ok, if you send e.g. full player positions each update.udp is faster than tcp, but as you can see, has to transport more data (in average).most games where many bullets are fired dont really animate the bullets correctly. a machine gun for example fires faster than anyone could see. its enough to send the position where a bullet hits the wall. or even this can be done by the client, and you may want to send a notification only when a player has been hit.a plasma rifle (like in quake3) fires many "bullets" that are relatively slow.to do this, you can use the direction the player is looking at when he shoots. as long as the bullets dont hit a target/player but just end on the next wall, every client can do the calculations, theres no need to be in sync.if you use a random modifier, you can let the server do the calculations and just transmit the direction. and the speed of the bullet is always the same, isnt it ? clients could take the last and the actual position of the player to calculate the player-speed that they have to add to the velocity of the bullet.in general, clients interpolate almost everything, while the server sends a status from time to time. just the actions that have consequences have to be transmitted correctly.and a last point:with some weapons it may be useful just to send "START_FIRING" and "STOP_FIRING" events.   ;  Thank you for reply!First of all:How can i let server do physics? for example, me(client) send at server that i press foreward and server porcess my position and send me it?I have understand?Second:in my game all bullets must be renderizable...so i have to really animated they.The problem is that i fire a lot of slow bullets, they must real hit wall, so all the clients have to see ecxatly the same bullet position!And if i send at server only start_fire and stop_fire it can't send at all players the position of all bullets...my game is a 2D action game, very similar at fps for the fast action but in 2d...like "Worms" but not turned based and the player bot can move very fast.   ;  The clients cannot be 100% in sync, unless you use the "lockstep" model, which traditionally requires that each action has some amount of latency (related to the networking round-trip time).I suggest you read the section on "what should I put in my packets" in the Forum FAQ. It has explanations of various models you can use to implement your networking.;  Thank i had already read those FAQ and i havent find my answare.What LOCKSTEP ecxatly means?All clients run same code in same time?What is your advice?I have some question:1)Client can process own position in local, or have to send it at server and server process new client position?2)When there are a fire event, what i must send to server and what i must receive from server?3)Client have to send update at server every game tick?4)Server have to send data at all clients as soon as receive data from one client?5)Only server have to know physics laws?6)If answer for 6 is true, how can i do?In my game,according to i have already wrote, there is a world whit some physics laws, all objects in this world are physics objects. So a bullet is a a physics object,influenced by Gravity force, attrition force, acceleration ecc ecc. So if only server can process bullets position, how can client know this position? Server have to send all bullets position at all clients...but i think this is impossible!My answars:1)I think yes, so owner can see own player run very smootly, and only other player are  process whit delay from net.2)I think i can send data to server, data contains position of fire, direction and force, server send this data at all clients(me too) so all can insert this bullet in own world.Certain this occurs in different time(cause net delay) but finally when bullet is in world it move at the same manner.3)I think yes becouse player can move very fast!4)I think serve have to store data in array, and send this array at all clints only 20-30 time per second.5)Now server only distruibutes data at all clients, only client have a copy of physics world.Plz answar at me,illustrate me where i fall in wrong way...im sure that im in a wrong way.   ;  I've found these two articles helpful:The Quake 3 Networking ModelSource Multiplayer Networking;1)Client can process own position in local, or have to send it at server and server process new client position?- usually the client sends everything to the server when there is a NEW action and  the server sends new response for all clients. meanwhile, the client keeps interpolating its old position depending on the speed and direction.2)When there are a fire event, what i must send to server and what i must receive from server?- the way i would handle it is keep the list of all the bullets everywhere:so every client just loops throught the list and interpolates the bullet according to a direction and speed and renders them.so: when player1 fires, player1 sends to the server a bulletPacket:{  - bulletposition  - bulletdirtection  - bullet speed}when the server receives such a packet, it would add the bullet to its list and send the packet back to all the clients, the clients just keep on interpolating the bullets in their list according to the specified values.the server is managing everything so the server checks for a change in direction or when the bullet collides with something or when it simply dies (ttl), and sends the appropriate packet to the client.3)Client have to send update at server every game tick?why?you only send a packet when something changes in the game, else you can interpolate the old position, until the speed or direction changes right?you can send a packet every few ms to keep everything in sync.4)Server have to send data at all clients as soon as receive data from one client?depends on the packet, if the packet affects all the players then yes.5)Only server have to know physics laws?of course, think of the clients as dumb rendering machines.6)I already answered this @ 2.a client just sends a create bullet message that the server takes and manage thru the whole game.to make sure you are not out of sync, it is a good idea to send a sync packet every few ms, which make sures all the clients have the same server values, if not, they interpolate to these values.hope this helps you a bit.;  Thank guy!!!! Now im write some code to try this new system, thank all for advice!   