ok hopefully i can make up for my comments in your last thread with some helpful feedback.
Simplest and crapiest solution. Create a set of AI animations, about 6. Let each one be different on each course, that's 18 different possible AI paths. Then all you have to do is play their animations based on a timer. e.g
var frame += .3
AI.gotoAndStop(Math.floor(frame))
Complecated solution. I'm guessing that this is art based, the solution would be much simpler if it were tile based but here goes.
create invisible boxes on all corner's of your maps, name them corner1, corner2, corner3 etc.
add this code to your AI.
code:
var currentCorner = 1;
var speed = 5;
onEnterFrame = function () {
var cornerClip = "corner"+currentCorner;
if (this.hitTest(cornerClip)) {
currentCorner++;
}
var ax = cornerClip._x-_x;
var ay = cornerClip._y-_y;
var angle = Math.atan2(ay, ax);
_rotation = angle/(Math.PI/180);
_x += speed*Math.cos(angle);
_y += speed*Math.sin(angle);
};
It should work, but it might look unrealistic, the AI's always going to look at the next corner perfectly, you could modify this by checking if the angle's greater or less than our current rotation. If so move the rotation based on an increment. If you use this method, you'll have to modify these codes:
_x += speed*Math.cos(_rotation*(Math.PI/180))
_y += speed*Math.sin(_rotation*(Math.PI/180))
