I am trying to understand how to implement and combine steering vectors for autonomous agents as described by Craig Reynolds.
My understanding is that each steering force should be calculated separately and then all of the steering forces should be added together and then applied.
I understand that each steering force is equal to the desired velocity for a particular behavior, minus the agent's current velocity.
I am trying to combine two basic behaviors: Seek and Flee. Below are two diagrams to illustrate my issue.
I have an agent that is Seeking a target directly ahead of it, and fleeing from a target below it. When the target is at rest (current velocity = 0), the steering forces for each behavior are equal to their respective desired velocities:
vSteer = vDesired - currentVelocity = vDesired - 0 = vDesired
And the combined steering force points up and to the right, in blue. This is roughly what I would expect.
However, if the agent is moving, we get a completely different result. For the sake of simplicity, say the agent is already moving at top speed in the direction of the target. So the agent's current velocity is equal to its desired seek velocity.
When the agent's current velocity is equal to the desired seek velocity, then the seek steering force is 0 (vSteer = current - desired = desired - desired = 0). The flee steering force then is equal to the desired flee velocity minus the current velocity, which produces a vector that points BACKWARD! And since the seek steering force is zero, the total steering force equals the flee steering force.
I noticed this issue while trying to implement a separation force, which is essentially the situation illustrated in the diagrams but with the red X representing a neighboring agent. The net effect is that agents maintain separation, but move at about half speed, with a seek steering force pointing forward, a flee steering force pointing backward and away from the neighbor, that largely end up cancelling each other out.
It really doesn't seem like any component of the flee force should be pointing backwards here. What am I misunderstanding?