Networking Questions
by Chris Haigler · in Torque 3D Professional · 06/05/2011 (7:44 am) · 0 replies
My project requires simulating a number of AI bots (up to 100 with most being visible/in scope at any given time). I have created a lightweight AIUnit class for this purpose (which is really nothing more than a stripped down combination of Player and AIPlayer derived from a very stripped down ShapeBase). Each AIUnit requires ~8 bytes for updates (packUpdate()).
With each AIUnit sending 8 bytes of data, simulating 100 of them requires $pref::Net::packetSize to be set to 850+ in order to fit all of the state updates in a single packet. Having such a large packet size isn't conducive for multiplayer but a smaller packet size will cause ghost updates to be split over multiple packets, with GameBase::getUpdatePriority() deciding when they occur. This causes ghost updates to be sent later than normal which causes AIUnits to 'warp' as they move on the client.
The 'warping' effect corresponds to how often ghost updates are received. Increasing $pref::Net::packetRateToClient causes the 'warping' effect to occur more frequently but reduces the warping distance whereas decreasing the packet rate reduces the frequency of warps but increases the warping distance.
Most interestingly, setting sMaxWarpTicks (found in the Player class) to something higher, from its default of '3' to, say, 20 allows the packet size to be set much lower without causing noticeable clientside warping.
With all of that said, here are my questions (finally!):
* What does Player::sMaxWarpTicks do, exactly? Looking at the code, it seems to determine how many 'ticks' it takes for the client ghost to 'warp' to the server position.
* Assuming the above is true, how does a large sMaxWarpTicks value affect things?
* How do Player::sMinWarpTicks and Player::sMaxPrediction ticks fit into all of this?
With each AIUnit sending 8 bytes of data, simulating 100 of them requires $pref::Net::packetSize to be set to 850+ in order to fit all of the state updates in a single packet. Having such a large packet size isn't conducive for multiplayer but a smaller packet size will cause ghost updates to be split over multiple packets, with GameBase::getUpdatePriority() deciding when they occur. This causes ghost updates to be sent later than normal which causes AIUnits to 'warp' as they move on the client.
The 'warping' effect corresponds to how often ghost updates are received. Increasing $pref::Net::packetRateToClient causes the 'warping' effect to occur more frequently but reduces the warping distance whereas decreasing the packet rate reduces the frequency of warps but increases the warping distance.
Most interestingly, setting sMaxWarpTicks (found in the Player class) to something higher, from its default of '3' to, say, 20 allows the packet size to be set much lower without causing noticeable clientside warping.
With all of that said, here are my questions (finally!):
* What does Player::sMaxWarpTicks do, exactly? Looking at the code, it seems to determine how many 'ticks' it takes for the client ghost to 'warp' to the server position.
* Assuming the above is true, how does a large sMaxWarpTicks value affect things?
* How do Player::sMinWarpTicks and Player::sMaxPrediction ticks fit into all of this?