Sign in to follow this  

Fighter jet AI (aim, follow etc.).

This topic is 3459 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How can I make my jets follow each other? This is the behavior I'm expecting: 1. It'd roll either left or right depending on whether its target is in its left or right side 2. Start pitching in the direction of the target. This seems to me to be the real life approach (roll then pitch). I know it's a lot more complicated than this but I want to have some kind of AI going. Basically I just want to know whether to turn left or right, or whether to pitch up or down. I'm not using using angles to represent orientation, just up, right front vectors. I foresee a lot of dot products :) Thanks.

Share this post


Link to post
Share on other sites
Basically, jets almost never pitch down. First the aircraft arent build to do that efficiently, and second the negative G's are really painfull to the pilots, if you would take the same negative G's as the positive G's, your eyes would burst out. This said..

The exact maths will depend on your physics model. Find the "plane" (in the geometry sense) you want to turn on, rotate around your front vector (roll) until your up-vector lies on that plane, and then rotate around your "side" vector.

Also, its probably unnecessary to keep a "right" vector? You can get it using the cross product....

When you can make the aircraft go wherever you want, then you can start to add simple things like lead pursuit, and then more complex manoeuvers.

Share this post


Link to post
Share on other sites
Hey thanks!

I was going going for the dot product between the (x-targ.x, y-targ.y...) vector and the (x+0, y+1, z+0) vector (local up) and that between the right vector and the (0,1,0) vector to be the same before starting to pitch. But now that you mention "planes", is suppose this planes will be defined by the three points (x,y,z), (front.x, front.y, front.z) and (targ.x,targ.y,targ.z) (the front vector being that of the aircraft in question).

If it's too complex, how can I find out if the up vector is lying in the plane defined by three points?

[quote]
Also, its probably unnecessary to keep a "right" vector? You can get it using the cross product....

When you can make the aircraft go wherever you want, then you can start to add simple things like lead pursuit, and then more complex manoeuvers.[quote]

I kind of have to upload the planes orientation in the modelview matrix so keeping track of all three vectors is easier for me. As for lead pursuit, if it's anything like 'target leading' then I got it covered :)

Share this post


Link to post
Share on other sites
Jets usually go either for a horizontal or a vertical fight, they rarely mix both too much, you should probably concentrate on horizontal fights first.

Anyway, if Im not drunk, the normal of your plane will be the cross product of your "front" vector and the vector to the "target". So you want to roll until your "side" vector is reasonnnably close to this vector.

Of course, this all assume an attack angle of zero, which is highly unrealistic.

Share this post


Link to post
Share on other sites
Ah of course the cross product would return the normal to the plane. I'm definitely not thinking straight.

Quote:
Anyway, if Im not drunk, the normal of your plane will be the cross product of your "front" vector and the vector to the "target". So you want to roll until your "side" vector is reasonnnably close to this vector.


Or until the dot product between the "up" vector and the normal nears zero :) I'll just get on with the coding now. Thanks a lot, big help.

[I didn't really get that about the angle of attack. I'll always be aiming for where the target is going to be (leading the target), if that's what you meant.]

Share this post


Link to post
Share on other sites
Quote:
Original post by glopen
Ah of course the cross product would return the normal to the plane. I'm definitely not thinking straight.

Quote:
Anyway, if Im not drunk, the normal of your plane will be the cross product of your "front" vector and the vector to the "target". So you want to roll until your "side" vector is reasonnnably close to this vector.


Or until the dot product between the "up" vector and the normal nears zero :) I'll just get on with the coding now. Thanks a lot, big help.

[I didn't really get that about the angle of attack. I'll always be aiming for where the target is going to be (leading the target), if that's what you meant.]


Angle of Attack

Share this post


Link to post
Share on other sites

This topic is 3459 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this