Elite NPC movement

Blitz3D Forums/Blitz3D Programming/Elite NPC movement

3 Vectors:

AI Ship's forwards vector =A
AI Ship's "up" vector =B
Vector of line from AI Ship to AI target ship. = C

Cross product of A & C should have the same direction (but not magnitude so convert the results to unit vectors) as the Cross product of B & C if I am understanding you correctly when the ship has rolled to its correct position.

Vector A does not change while rolling.
So you want to roll the craft until the direction of the vector A x C equals the direction of the vector B x C

So:
Calculate A x C and convert the resulting vector to a unit vector (ie length of 1).

Calculate B x C and convert it to a unit vector as well.
Roll the craft and check again.

When the difference between these two resulting unit vectors is small then you have gotten pretty darn close to having the correct roll and you can then start pitching.