307
18
BelievableDeadReckoning
forNetworkedGames
Curtiss Murphy
Alion Science and Technology
18.1Introduction
Your team’s producer decides that it’s time to release a networked game, saying
“We can publish across a network, right?” Bob kicks off a few internet searches
and replies, “Doesn’t look that hard.” He dives into the code, and before long,
Bob is ready to begin testing. Then, he stares in bewilderment as the characters
jerk and warp across the screen and the vehicles hop, bounce, and sink into the
ground. Thus begins the nightmare that will be the next few months of Bob’s life,
as he attempts to implement dead reckoning “just one more tweak” at a time.
This gem describes everything needed to add believable, stable, and efficient
dead reckoning to a networked game. It covers the fundamental theory, compares
algorithms, and makes a case for a new technique. It explains what’s tricky about
dead reckoning, addresses common myths, and provides a clear implementation
path. The topics are demonstrated with a working networked game that includes
source code. This gem will help you avoid countless struggles and dead ends so
that you don’t end up like Bob.
18.2Fundamentals
Bob isn’t a bad developer; he just made some reasonable, but misguided, as-
sumptions. After all, the basic concept is pretty straight forward. Dead reckoning
is the process of predicting where an actor is right now by using its last known
position, velocity, and acceleration. It applies to almost any type of moving actor,
including cars, missiles, monsters, helicopters, and characters on foot. For each
308
remote
a
dates a
b
orientati
position
next up
d
Bob is r
i
a differe
Myth
Let’s
s
netwo
r
knowl
e
exact
s
packet
percei
v
perfec
t
Basic
M
To deri
v
network
.
first kin
e
straight
f
the valu
e
it at ve
l
reckone
d
a
cto
r
b
eing
c
b
out its kine
m
on, and angu
l
we received
d
ate, we do
s
i
ght that the
fu
n
t story.
Busting—
G
s
tart with the
r
ked enviro
n
e
dge of the s
s
tate of all re
m
loss, zero l
a
v
ed
t
ruth. Th
u
t
re-creation.
M
ath
v
e the math,
w
.
In this case,
e
matic state
u
f
orward linea
r
e
s from the
m
l
ocity
0
V
wi
t
d
position
t
Q
1
c
ontrolled so
m
m
atic state t
h
l
ar velocity.
I
on the netw
o
s
ome sort of
fu
ndamentals
G
roundTr
u
following fa
c
n
ment. “Gro
u
tate of all ac
m
ote actors
w
a
tency envir
o
u
s, the goal
b
w
e start with
t
one of our o
p
u
pdate as it c
a
r
physics pr
o
m
essage, we
p
t
h accelerati
o
at a specific
t
t
Q
P
Figure 18.1
.
8.Believabl
e
m
ewhere els
e
h
at include i
t
I
n the simple
s
o
rk and proje
c
blending an
d
aren’t that c
o
u
th
c
t: there is n
o
u
nd truth”
i
tors at all ti
m
w
ithout sendi
n
o
nment. Wha
t
b
ecomes beli
e
t
he simplest
c
p
ponents is
d
a
me into vie
w
o
ble
m
, as de
s
p
ut the vehicl
e
o
n
0
A
, as s
h
t
ime T is calc
00
1
2
T
P
V
A
.
The first upd
a
e
DeadReck
o
e
on the net
w
t
s position,
v
s
t implement
a
c
t it forward
d
start the p
r
o
mplex, but
m
o
such thing
a
i
mplies that
m
es. Surely,
y
n
g updates e
v
t
you have i
n
e
vable estim
a
c
ase: a new a
c
d
riving a tank
w
. From he
r
e
s
cribed by A
r
e at position
h
own in Fi
g
c
ulated with t
h
2
0
T
A
.
a
te is simple.
o
ningforNet
w
w
ork, we rec
v
elocity, acc
e
a
tion, we tak
e
in time. The
n
r
ocess all ov
e
m
aking it beli
e
a
s ground tr
u
you have
p
y
ou can’t kn
o
v
ery frame in
n
stead is yo
u
a
tion, as opp
o
ctor comes a
c
, and we rec
e
e
, dead recko
n
r
onson [199
7
0
P
and begi
n
g
ure 18.1. T
h
h
e equation
w
orkedGam
e
eive up-
e
lera
t
ion,
e
the last
n
, on the
e
r again.
e
vable is
u
th in a
p
erfect
o
w the
a zero
u
r own
o
sed to
c
ross the
e
ived our
n
ing is a
7
]. Using
n
moving
h
e dead-
e
s
Get Game Engine Gems 2 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.