   primitive AI for plane
  Hi,I m trying to make a simply flying arcade game, and the worst thing for me is to make a function AI... Check this picture: Question is, how can the blue plane detect, if the red plane is on the left, or on the right side?thanks   
  first of all, your picture is funny, is the plane game like asteriods movement or like horizontal shooters like rtype.if it is like rtype you could do something like this int GetSide(Object redPlane, Object bluePlane){int side=0;if(((redPlane.x-bluePlane.x)<CONTACT_DISTX)&&((redPlane.y-bluePlane.y)CONTACT_DISTY)){if(redPlane.y + redPlane.height >= bluePlane.y + bluePlane.Height)side = LEFT_SIDE;if(redPlane.y + redPlane.height <= bluePlane.y + bluePlane.Height)side = RIGHT_SIDE;}return side;};  Dot products are your friend :) Get the vector from your ai plane to the other plane and do a dot product with the ai planes x (right) axis.Greater than 0 on the right, smaller than zero on the left. Similarly you can do the same with the planes z (forward) axis to determine if its in front or behind you!Edit :- the poster above my example will only work for planes facing upwards, as mentioned, in games such as r type, if you are looking for a more flexible solution. I suggest you read up on vectors, and matricies once you get your head round them they are actually pretty easy and can save lots of time and headaches! :)Cant remember where it was quoted but "Dot products are the swiss army knife of game development";Quote:Original post by lodoss118first of all, your picture is funny, is the plane game like asteriods movement or like horizontal shooters like rtype...no, it will be simply 3d game created in blitz 3d... but thanks for reply :)Quote:Original post by chipmeistercDot products are your friend :) Get the vector from your ai plane to the other plane and do a dot product with the ai planes x (right) axis.Greater than 0 on the right, smaller than zero on the left. Similarly you can do the same with the planes z (forward) axis to determine if its in front or behind you!Edit :- the poster above my example will only work for planes facing upwards, as mentioned, in games such as r type, if you are looking for a more flexible solution. I suggest you read up on vectors, and matricies once you get your head round them they are actually pretty easy and can save lots of time and headaches! :)Cant remember where it was quoted but "Dot products are the swiss army knife of game development"it sounds good, i try it with dot product, thanks