1
\$\begingroup\$

I'm reading Programming Game AI by Example, by Mat Buckland. What I don't understand there is why the individual behaviors return a vector representing change in velocity, but the combined result is treated as a force vector.

Here's the excerpt from the update function:

  Vector2D SteeringForce = m_pSteering->Calculate();

  //Acceleration = Force/Mass
  Vector2D acceleration = SteeringForce / m_dMass;

  //update velocity
  m_vVelocity += acceleration * time_elapsed; 

  //make sure vehicle does not exceed maximum velocity
  m_vVelocity.Truncate(m_dMaxSpeed);

  //update the position
  m_vPos += m_vVelocity * time_elapsed;

And m_pSteering->Calculate() returns the weighted sum of different steering "forces", like Seek

Vector2D SteeringBehavior::Seek(Vector2D TargetPos)
{
  Vector2D DesiredVelocity = Vec2DNormalize(TargetPos - m_pVehicle->Pos())
                            * m_pVehicle->MaxSpeed();

  return (DesiredVelocity - m_pVehicle->Velocity());
}

So, how come steering functions like Seek just return change in velocity and don't take mass into account, but still get used as force?

Here's the source code

\$\endgroup\$
2
  • \$\begingroup\$ did you see this tutorial. \$\endgroup\$ Commented Nov 1, 2018 at 4:35
  • \$\begingroup\$ @SeyedMortezaKamali I looked at the tutorial, it seems to be using the same formulas, but still doesn't explain the point I'm confused about. \$\endgroup\$ Commented Nov 2, 2018 at 19:34

1 Answer 1

1
\$\begingroup\$

The guy who wrote the original steering behaviors stuff was a little sloppy about accelerations versus forces. They differ, of course, only by a factor of the agent’s mass. In many multi-agent steering-behavior based systems mass is ignored, or set to one, which makes accelerations and forces equivalent. You tend to spend a lot of time tweaking with the strength and weighting of the steering forces, and how they get combined, so the units of mass (or non-unit values) can often be ignored. The more you care about the actual physics, the more you care about realistic values of mass, force, and acceleration.

\$\endgroup\$
1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .