# Enemy AI for platformers

**URL:** https://forum.kirupa.com/t/enemy-ai-for-platformers/146672
**Category:** Uncategorized
**Created:** [May 3, 2005, 11:00am UTC](https://forum.kirupa.com/t/enemy-ai-for-platformers/146672 "2005-05-03T11:00:11Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Dark\_Toast](https://avatars.discourse-cdn.com/v4/letter/d/f1d935/32.png) [@Dark\_Toast](https://forum.kirupa.com/u/Dark_Toast)
#### Post date: [May 3, 2005, 11:00am UTC](https://forum.kirupa.com/t/enemy-ai-for-platformers/146672/1 "2005-05-03T11:00:11Z")

</div>

Hi,I am making a platform game.I know how to make the character move,jump,attack…I just need some help with AI.I understood the enemy AI basics.I want the enemy to follow you when you reach a certain distance from him.  
I want him to be able to block and attack.I saw some AI codes which were a little buggy and had syntax errors.most of them had sometging like

chancesofblock = random(100);  
if(Key.isDown(Key.SPACE) && \_root.hero.hitTest(\_root.enemy)&&  
chancesofblock \<50)  
//enemy’s death code here

The game is going to be a bit like [http://www.newgrounds.com/portal/view/234470](http://www.newgrounds.com/portal/view/234470)
