   Handling rotation
  Good morning gentleman,i am in the middle of coding a small game that would allow LAN players to fight and enjoy the physics around. The idea is to run / shoot on a flat map surrounded by walls. Nothing special but the challenge is to have it all synched and running with Tokamak physics. To the point.Game clients rotate by moving the mouse, the rotation is done within Y angle so when you hit "WALK FORWARD" you can rotate in any moment what will affect your position.Right, i've already made a server/client template and i am using TCP for this game. Authorization is done, gamestate packets are completed, map loading etc.etc...The problem itself:- When i hit "WALK FORWARD" on the client, player state packet is sent to the server. Packet data: (*(int *)(gotopacket))=NETWORKPACKET_START;    //PACKETSTART value(*(int *)(gotopacket+BYTE_SPACE))=NETWORKPACKET_GOTO;  //PACKET type(*(float *)(gotopacket+(BYTE_SPACE*2)))=PLAYERS[PLAYERS_MYPLAYER].rot; //ROTSo All we require to have it running is a rotation angle as server continously calculates all positions and runs the physics engine too.- Server receives the packet, - Server sets player[x] rotation to the one received from packet above- Server sets player[x].move=1 flag so the physics now start calculating new positions- Server broadcasts GOTO packet to all players on the map :(*(int *)(gotopacket))=NETWORKPACKET_START;(*(int *)(gotopacket+BYTE_SPACE))=NETWORKPACKET_GOTO;(*(int *)(gotopacket+BYTE_SPACE*2))=i;  //player who starts walking(*(float *)(gotopacket+BYTE_SPACE*3))=rot; //his rotation- Players receive the packet, set the rotation and run simulation on walking player.The problem :While 'walking' - i decided to rotate, turn around a bit left-right...If i would send every rotation update to server this would cause a big and non efficent flood.The idea i have woke up today with:(client) Send PDU (player data unit) packet with rotation to server every X ms.(server) Broadcast players's PDU to all players excluding the one sending PDUThe pseudocode:timer(){if(player[myplayer].actualrotation!=player[myplayer].lastsentrotation) network_send_new_rotation(myplayer)settimer(10ms,timer);}The above was not tested yet, if this is something what would satisfy LAN playing for up to 4 players ( not more, as this is a proof of concept not a release ) - i would like to ask you gently guys - how often such packets should be sent from clients to server, i know you might have some suggestions and i really appreciate any comment on this.As usual - many thanks and greets to all codemasters and gamedev site![Edited by - dirtysanchez on May 5, 2009 3:53:31 AM]
  I think i might enlighten this a bit.Server sends state packet (PDU) every 500ms to all players.This packet consist of a :- position ( x,y,z )- rotation ( y )It is a broadcast packet, so every player receives informations regarding others.I have implemented my morning 'idea' which sends 'rotation' data to serverin this way:every 100ms send my rotation to server (if rotation changed)server receives this data and updates the rotation state in the worldNow, when i walk forward i am kinda 'synchronized' - it means i am happy and i can 'apply' some interpolation to have the players moving smoothly.The problem occurs when i rotate while walking.I run forward and apply rotation from left to right and i get really really poor results with this. I can explain myself the issue here, but still im trying to find out the best solution for such a scenarios.What and how exactly rotation should be processed in multiplayer fast games?I move forward and do the rotationshow often and when exactly should i inform server about my changing state?YouTube video explaining the issue:;  Look at the EPIC library for interpolation, which shows how rotating while moving will cause a "balloon turn" on extrapolated clients. With extrapolation, there's really nothing you can do about it.Regarding how often you need to send updates, that depends on gameplay. FPS games benefit from updates 30 times a second, but that may be too much for a large game server. Older Quake servers often used 10 times a second. Some MMO RPGs use 2 or even 1 time a second.   ;  hplus0603 - this is true, i've been developing a mmorpg 'poc' (proof of concept) called >Szczerbiec few months ago - server capable for handling 255 players per sector. And the bandwith usage was so low due to per-click movements and updates.So - just to summarize.I have finally found a 'small' solution for my problem,it happened that rotation changes (angle) were not so fast as they should be.Client is sending rotation updates 20times per second if:rotation != previous sent rotation && movingAs for a 'straight forward walk' a sshot made represents a very nice synchronisation with server side tokamak engine.As far as distance (difference) between blue/white boxes [ server pos / client pos ] do not reach more than 1m (1.0f) it is really okay for my gameplay now.Below comes the shot of a turn made during transition [walk]Difference went into 0.8 but immediately came back to lower value.I'll look at the EPIC and see what else can be done to tune this up a bit.Many thanks - i'll keep this post updated.[Edited by - dirtysanchez on May 5, 2009 1:56:40 PM]