tux
20-03-2006, 10:30 PM
Im having really big problems with getting AI to work in our entry. My maths is really lacking so here is a plea for help from you smart people.
I'm trying to make my AI look at the player but what ever i try wont work. I have 2 vectors, Player and AI position. currently im 0ing out the Y components (i only want to work in 2D for the steering) and normalizing the 2 vectors.
then i get the cross product between the 2 and then the cross product between that result and the AI. then i get the dot product between the last cross product and the AI. i think im missing something but i dont know what :(
T := AffineVectorMake(Tank.Matrix[3]);
T[1] := 0;
U := AffineVectorMake(GUserTank.Matrix[3]);
U[1] := 0;
VectorNormalize(T);
VectorNormalize(U);
Cross := VectorCrossProduct(T, U);
Cross := VectorCrossProduct(Cross, T);
Dot := VectorDotProduct(Cross, T);
if Dot > 0 then
Tank.Steer := 1 // steer 1 = turn left
else
Tank.Steer := -1; // steer -1 = turn right
if i cant get this going then the competition entry will just be the player driving around hitting static targets (and how boring will that be!)
I'm trying to make my AI look at the player but what ever i try wont work. I have 2 vectors, Player and AI position. currently im 0ing out the Y components (i only want to work in 2D for the steering) and normalizing the 2 vectors.
then i get the cross product between the 2 and then the cross product between that result and the AI. then i get the dot product between the last cross product and the AI. i think im missing something but i dont know what :(
T := AffineVectorMake(Tank.Matrix[3]);
T[1] := 0;
U := AffineVectorMake(GUserTank.Matrix[3]);
U[1] := 0;
VectorNormalize(T);
VectorNormalize(U);
Cross := VectorCrossProduct(T, U);
Cross := VectorCrossProduct(Cross, T);
Dot := VectorDotProduct(Cross, T);
if Dot > 0 then
Tank.Steer := 1 // steer 1 = turn left
else
Tank.Steer := -1; // steer -1 = turn right
if i cant get this going then the competition entry will just be the player driving around hitting static targets (and how boring will that be!)