Shop Forum More Submit  Join Login
Learn how to create basic artificial intelligence in your game using actionscript 2.

Click the link to see a tutorial on how to make your flash game's enemies follow and attack the character when it is in range and download the .fla.
Add a Comment:
 
:icongraphik2d:
Graphik2d Featured By Owner Oct 1, 2009
here is a little something you might want to add in order to avoid your ai fighting agaisnt nothing when you stand behind him and you are still at a fighting distance.If you already have something similar remove it from where you check the distance.

/*this is to not let the ai turn if he has already started punching assuming the first frame is a neutral stance */
if(_root.myEnnemy._currentframe!=1){
root.myEnnemy.attack=true
}else{
root.myEnnemy.attack=false
}

if(!_root.myEnnemy.attack){
if(_root.myHero._x>_root.myEnnemy._x){
root.myHero._xscale=-100
root.myEnnemy._xscale=-100
}else{
root.myHero._xscale=100
root.myEnnemy._xscale=100
}
}
Reply
:iconfreelanceflashgames:
FreelanceFlashGames Featured By Owner Apr 17, 2009
Thanks.
Reply
:iconnagagg01:
nagagg01 Featured By Owner Apr 16, 2009
very nice.
Reply
:iconhat-man:
hat-man Featured By Owner Apr 15, 2009
great work on this :D
this actionscript could be very useful
Reply
Add a Comment:
 
×




Details

Submitted on
April 15, 2009
Image Size
5.1 KB
Resolution
400×150
Link
Thumb

Stats

Views
3,937 (1 today)
Favourites
4 (who?)
Comments
4
Downloads
197

License

Creative Commons License
Some rights reserved. This work is licensed under a
Creative Commons Attribution-No Derivative Works 3.0 License.