Table of Contents
The movement controller needs to maintain a set of state variables that are used to control the bot's movements.
For example, the GraphTraverser
movement
controller in
src/server/tools/bots/patrol_graph.
keeps track of the following information:
[ch]
pp
-
A graph that the bot is traversing.
-
The node towards which the bot is heading.
-
A position near that node toward which it is actually heading.
-
A timer for spending time at a given node.
The most important part of the movement controller is the
nextStep()
method:
bool nextStep( float & speed, float dTime, Vector3 & pos, Direction3D & dir )
The dTime
parameter is the time elapsed since
the last call to nextStep()
.
Aside from updating any state variables as necessary, the general
function of this method is to establish some unit vector the bot is
moving down, and to update pos
and
dir
appropriately, according to the formula
below:
pos += unitvec * (speed * dTime);
dir.yaw = unitvec.yaw()