I have a real time game on a hex-based map. So far I’ve been lazy and restricted movement to just one hex at a time. This way the server verifies the target hex is empty, and the character occupies both hexes until the walk animation is complete. What are some approaches for allowing movement over multiple hexes? I’m pretty flexible on the rules, but ideally I would like other characters to block movement, and I’d like other characters to be able to attack the moving character as he goes by.
If I extend my current mechanism then the character will walk one hex, pause while it waits for the server to verify the next hex is empty, then walk to the next hex. While this gives me a simple, sure-fire way to deal with movement, I have a feeling that walk-pause-walk-pause-walk will not look good.
Ping on over 3G on a cell phone can be 600ms. This makes the pauses pretty brutal, but also means client-side prediction can get things very wrong. Maybe I could allow prediction of at most one hex? If a character completes the walk animation to the next hex but hasn’t yet gotten server authorization to move there, then it would pause before continuing. For a rollback I guess I could have the character turn around and walk back to where he came from.
Prediction is pretty complex. I’d like to keep it as simple as possible. Just thought of an optimization to the first mechanism… instead of the client moving one square, then requesting to move another, it would tell the server the entire path the character wants to make. The server would then send a “move” command at the proper intervals, cutting the latency in half. Maybe this would work well on WIFI and be good enough for 3G?
I thought about a different approach… when a movement is first chosen, the pathing is done and the server authorizes the entire path. During movement, no further checking is done – the character would just walk through any obstacles that appear. This is kind of lame and means the character doesn’t actually occupy each hex as he moves, so he can’t be attacked or otherwise affected, which doesn’t make much sense.
Any other ideas?