Steering behaviour seek with constraints

E96bdd9352bdf5f0e17646cd08c83b0e
0
yakul 101 Jun 25, 2007 at 10:58

I am creating a space ship battle game and I am working on the AI of the enemy ships.
The ships can rotate with a Yaw, Pitch and Roll and can generate force in the direction of the heading of the ship. It means that in order for the ship to generate a force in an arbitrary direction it need to rotate its head to that direction first.
Now I am trying to implement some steering behaviours, such as seek.
I have the book programming Game AI by Example in there the 2D seek is as such:
Vector V = (TargetPos-Vehicle->Pos).Normalize()*Vehicle->MaxSpeed;
return V-Vehicle->Velocity;

I also create a force to movement translator, which means that if the steer gives a desired force to the space ship, the translator will translate this into rotation and forward force.
So if the desired force is in the opposite direction of the head of the ship, the ship will only rotate without generating forward force.
If I implement the above seek behavior, the problem is that the ship may constantly swing and rotate from left to right when I do pursuit which use seek, because the seek gives a force the is far from the heading of the ship and from the line connecting the positions of the two ships.
So what I did instead:

Vector V = (TargetPos-Vehicle->Pos).Normalize*Vehicle->MaxSpeed;
return V*0.5+(V-Vehicle->Velocity)*0.5;

I dont get the swinging and rotation jittering of the ship, and it chase the target quite ok, but then the enemy ship wont chase the target optimally?

So, do you have any suggestions how to implement seek?

0 Replies

Please log in or register to post a reply.

No replies have been made yet.