About steering and velocity

Started by
0 comments, last by ApochPiQ 9 years, 10 months ago

I was reading couple of tutorials regarding steering behaviour and there is one thing that confuses me.
To calculate position for my agent i need to sum up all steer forces and accumulate into velocity:

steerForce = calculateSteeringForces();
steerForce.truncate(maxForce);
velocity += steerForce;
velocity.truncate(maxSpeed);
position += velocity;

I will take seek behaviour for example:
desiredVel = normalize(target - agent.position) * maxVel;
return desiredVel - agent.velocity;

and at some point i need to stop my agent from moving, should i check magnitude of steerForce like:
steerForce = calculateSteeringForces();
if(steerForce.length() < epsilon)
    return; //stop
steerForce.truncate(maxForce);
velocity += steerForce;
velocity.truncate(maxSpeed);
position += velocity;

because velocity is always > 0.
Advertisement
"Seek" will rarely give you a force that results in stopping. If you want to land on a specific target, you should use the "Arrive" force.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

This topic is closed to new replies.

Advertisement