• Advertisement
Sign in to follow this  

flash enemy AI

This topic is 4383 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So far i have created an enemy and a character for an RPG game The enemy is randomly walking, and palys teh correct animation for each of the four directions The enemy has a range, if the character enters this range it will do SOMETHING This SOMETHING however i do not know how to do.... I want the enemy to WALK towards the charcter in a way similar to the way i have developed the rest of the code and animation ... Once the character walks outside of the range again, it will randomly walk again. Could someone please please help me, cos this has got very frustrating over the past couple of days, and im out of ideas... If the code below is not enuf for oyu to help ----------------------------------------------- The code below is applied to the movieclip, "enemy" the SOMETHING i want it to do is the area of question marks onClipEvent (load) { lock = true; up = 1; down = 2; right = 3; left = 4; speed = 4; none = 0; dir = random(4)+1; // initial direction off = true; damage = 0; all = true; function checkproximity() { // check proxymity dist_hero = 120; // check distance dx = _x-_root.hero._x; dy = _y-_root.hero._y; dist = Math.sqrt(dx*dx+dy*dy); // increase speed // check if hero dist is < 100 if (dist<dist_hero) { in_range = true; } else { in_range = false; lock = true; speed = 2; } } function follow() { if (in_range) { // if in range follow if (this.hitTest(_root.hero.hit)) { xstep = _root.hero.xstep; ystep = _root.hero.ystep; } lock = false; ????????? ????????? ????????? ????????? ????????? ????????? ????????? ????????? ????????? ????????? } } }

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement