Hi there,
so if you just need the 2D variant, why don't you use the ArcTan2 function from delphi?
The result contains the angle of the given point. So your point should be PosX-PlayerPosX, PosY-PlayerPosY.
Since your enemy must have an own "looking at"-angle too, you can now consider if the angle is bigger or lower to steer left or right.
EnemyToPlayerAngle := ArcTan2(PosX-PlayerPosX, PosY-PlayerPosY);
if EnemyAngle < EnemyToPlayerAngle then
Steerleft
else
Steerright;
This is not the exact solution, but it should give you a guess how to use ArcTan2 function. Also you may translate the angle to degrees (using radtodeg-function) since the function returns radians as far as I remember, don't know with what you are calculating.
Hope that helps. I use this in my Tanx entry, too. So I know that it works.
Bookmarks