Basic Steering Behaviors.

Started by
3 comments, last by Timkin 15 years, 10 months ago
I'm having trouble understanding the physics equations related to Steering Behaviors For Autonomous Characters (present in the book "Programming Game AI by example"). In the book, Mat Buckland calculates Seek like so (in Pseudocode) def Seek() DesiredVelocity = Normalize(TargetPos - VehiclePos) * VehicleMaxSpeed SteeringForce = DesiredVelocity - VehicleVelocity return SteeringForce Seek is stated, in the book- to return a steering force, which is "the force required, when added to the agents current velocity vector, gives the desired velocity. How does the subtraction of two velocity vectors suddenly become a force? My heads in a spin- any help is greatly appreciated!
Advertisement
the terminology seems a bit confusing, you are right.
first of all... the output is not a real force but a "change in velocity" which is kind of similar, but physically not the same.
anyway, the idea is to move the agent as fast as possible toward the target position. As fast as possible means that the agent usually has a steering ability, in this case represented by the VehicleMaxSpeed... but you should probably read it as "maximum change in velocity".
hope this helps.


Quote:Original post by Metro_Mystery
I'm having trouble understanding the physics equations related to Steering Behaviors For Autonomous Characters (present in the book "Programming Game AI by example").

In the book, Mat Buckland calculates Seek like so (in Pseudocode)

def Seek()
DesiredVelocity = Normalize(TargetPos - VehiclePos) * VehicleMaxSpeed
SteeringForce = DesiredVelocity - VehicleVelocity
return SteeringForce

Seek is stated, in the book- to return a steering force, which is "the force required, when added to the agents current velocity vector, gives the desired velocity.

How does the subtraction of two velocity vectors suddenly become a force?

My heads in a spin- any help is greatly appreciated!


Lets see... Desired Velocity... Velocity should be a speed with a direction...

*Pos is place only, so in SI, m. *Speed is m/s. So (m) * m/s = m**2/s. So we don't even have a velocity right now. And velocity, no matter how you add or subtract it, cannot equal force. I would say look at his other code, and most likely he doesn't actually want force to be returned, and he has misnamed it.
If history is to change, let it change. If the world is to be destroyed, so be it. If my fate is to die, I must simply laugh.- Magus
Thanks for the replies guys,

Would it be correct to say that he's obtaining the "force" vector assuming the constant scaling factor in F = m/t(v-u) [m/t] is 1kg/1sec?

In that case the force vector + the current velocity vector will indeed give the desired velocity vector.
It's not mis-named... it's simply an approximation. The difference of velocities is a first order approximation of the acceleration needed to change velocity in a single frame. Acceleration is linearly proportional to force (F=ma). Typically the returned value is weighted by two factors, the mass of the object (most applications assume unit mass) and a factor that determines the number of frames over which the acceleration should actually produce the convergence to the desired point. Given that this is an iterated solution method for at least one moving target, the acceleration required at the next iteration will not be the same. Indeed, one can prove that for a stationary target and a simple motion model, this technique will provide convergence of position to the target. The limits of discrete numerical computations will cause some instability very close to the target point, but this is easily dealt with by using a deadzone around the target point within which the velocity is set to zero.

Regards,

Timkin

This topic is closed to new replies.

Advertisement