I've seen lots of examples of theory about the reason for client-side prediction, but I'm having a hard time converting it into code. I was wondering if someone knows of some specific examples that share some of the code, or can share their knowledge to shed some light into my situation.
I'm trying to run some tests to get a the movement going (smoothly) between multiple clients. I'm using mouse input to initiate movement.
I'm using AS3 and C# on a local Player.IO server. Right now I'm trying to get the Client side working, as I'm only forwarding position info with the client.
I have 2 timers, one is an onEnterFrame and the other is a 100ms Timer, and one on mouseClick listener.
When I click anywhere with a mouse, I update my player class to give it a destination point
On every enterFrame Event for the player, it moves towards the destination point
At every 100ms it sends a message to the server with the position of where it should be in a 100ms.
The distance traveled is calculated by taking the distance (in Pixels) that the player can travel in one second, and dividing it by the framerate for the onEnterFrame handler, and by the update frequency (1/0.100s) for the server update.
For the other Players, the location is interpolated and animated on every frame based on the new location.
Is this the right way of doing it?