4 connected clients each running at a different FPS, each with different ping/pong times, requires Frame rate independent movement
Using the elapsed time between frames to update the position , 1000/60 elapsed time = 16.6.
One method is reading keyboard input detecting directional changes, recording a time stamp and position for each directional change, this information is sent back to the server on average once every 200 milliseconds.
The sever as a tick rate of say 5 ticks for each second of time.
The server and client can use a buffer of previous player positions to achieve movement interpolation, this approach can’t be used for PVP in real time as there is no prediction ahead of time for the new player positions.
Projectiles can have predetermined behaviour using a sine wave generator, the client sends a player shoot packet back to the server, included is the position, angle and a time stamp, the server positions each projectile based of it’s elapsed time from being alive, With this information the server checks to see the bullet isn’t being positioned elsewhere and proceeds to send all connected clients the ally shoot packet.
gareth_mcdaidMember Since 22 May 2007
Offline Last Active May 18 2014 06:38 PM
- Group Members
- Active Posts 7
- Profile Views 938
- Submitted Links 0
- Member Title Member
- Age Age Unknown
- Birthday Birthday Unknown