不確定な遅延のある通信環境での位置同期はどうなっているのか

即着弾系の銃器をもって走り回るFPSでは全ての接続されてるクライアント上での座標をある範囲の正確さで同期してやる必要がある。

あるプレイヤーが操作しているクライアントではプレイヤーがキーを押した瞬間に動き出さなくてはならない一方で、その際に発生した動き出した情報にしろ止まる情報にしろ、必ず遅れてその他のクライアントへと伝達されることになる。このため他人が狙っている他人から見た自分と、自分が動かしている自分とはどうしても同時点での位置にズレが生じる瞬間が存在することになる。

ローカルクライアント上の自PCの挙動と、それがネットワーク越しの他クライアント上でどのように再現されるかを算出するルーチンを調整し、このズレる瞬間を誤魔化さなくてはならないのだが、ここで以下4つの要素のバランスをとることが求められる。

  • 操作するプレイヤーには操作上のフラストレーションを与えない
  • 実際に他人が狙う位置と自分がいると認識させる位置とのずれを最小限に抑える
  • ネットワーク越しのPCの動きにおける不自然なワープを抑える
  • できる限りの範囲で遅延の多いものも少ないものと同じように再現する

まだ調整途上だけどデモを作ってみた。

The wooden box is local caharacter which you control on your client. The water box is how your character's movement is looks like on other remote machine. Its movement is made from the data of when and which direction the wooden box is ordered to go or stop, which is sent and recieved with some latency.

Note that wooden one's movement is little sticky. That means every movement you apply takes some millisecs to start and to stop. With that fact remote machines can predict the position of remote characters even using information recieved late. And that also helps to keep those movement with no unnatural positional jump.

Try change the latency and move the box around and see what happen on movement of the water box.

http://az1049.hp.infoseek.co.jp/misc/predictor.zip