Hi,
I’m working on a network game but have been struggling with the client timing issues - I’m trying to allow the game to be tolerant of very high latency and I’m doing it by rewinding back to the lagged event, applying it, then fast-forwarding to the current time. The problem is that the symmetrical rewind and fast-forward of the game world is difficult… The two biggest problems are that the game logic needs to be independent of the frame-rate (which is not fixed), and that negative time updates need to reverse positive time updates.
So here’s a maths problem that I can’t solve:
[i]
A player is moving from point A with a horizontal and vertical velocity of Vx and Vy respectively for a period of time t. He attempts to aim his turret at a fixed point M as he travels along, however his turret can only move at a maximum angular velocity of Va. At point A his turret is at angle Alpha.
What is the equation for the turret angle Beta at time t?[/i] :-\ ???
Here’s a simplified diagram, where Vy is zero and Alpha, the initial turret angle at point A, is equal to the angle of M from point A:
http://www.freewebs.com/commanderkeith/random/mathsProblem.PNG
I don’t know how to solve it. I would like to know the answer since with this equation I could make perfectly-reversible updates to the player’s turret angle using different values for t. By the way, t is the time between frames, or the ‘delta’, and M is the mouse pointer where the turret is meant to aim.
Currently I just figure out the angle Theta that the turret needs to rotate through as the player moves between points A and B, where B is wherever the player ends up after time t. If time t multiplied by the maximum angular velocity is less than Theta, I rotate by that t times the maximum angular velocity. Otherwise I just rotate the turret by Theta.
The problem with this approach is that if lots of small updates are done, so t’s are small, then the rotation of the turret is less than if t’s are big. This means that a high-frame rate player (with small t’s) turns his turret slower than a slow-frame rate player, causing trouble for me since then the server and client get out of sync. I think that this occurs because if the turret were to point at M the whole time, the rate of change of the turret angle is greatest when the player is close to H compared to when it is far away. So the maximum rotation limit only affects the turret at certain times when the player is close to H. But if t is large, then the (average) angular speed may not exceed the maximum angular speed, even though it would have for a certain portion of time.
If anyone finds this kind of maths-challenge interesting, it’d be a great help!
Thanks,
Keith