# Need help with ai

**URL:** <https://forum.kirupa.com/t/need-help-with-ai/205019>\
**Category:** Uncategorized\
**Created:** [October 25, 2006, 1:03pm UTC](https://forum.kirupa.com/t/need-help-with-ai/205019 "2006-10-25T13:03:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![master\_psin](https://avatars.discourse-cdn.com/v4/letter/m/f0a364/32.png) [@master\_psin](https://forum.kirupa.com/u/master_psin)\
**Post date:** [October 25, 2006, 1:03pm UTC](https://forum.kirupa.com/t/need-help-with-ai/205019/1 "2006-10-25T13:03:04Z")

</div>

im making a fighting game and i need an opponent to fight back atm ive got  
mc for standingin frame 1 walking frame2 and fighting frame 3-4 what type of code do i need so that he will walk and attack, and do damage?

---

<div class="post-metadata">

**Author:** ![SacrificialLamb](https://avatars.discourse-cdn.com/v4/letter/s/6f9a4e/32.png) [@SacrificialLamb](https://forum.kirupa.com/u/SacrificialLamb)\
**Post date:** [October 25, 2006, 8:27pm UTC](https://forum.kirupa.com/t/need-help-with-ai/205019/2 "2006-10-25T20:27:51Z")

</div>

is the game top down or side on?  
for side on

```auto
if (char._x-range>enamy._x){
enamy.gotoAndStop(2)
enamy._x+=speed
} else if (char._x+range<enamy._x){
enamy.gotoAndStop(2)
enamy._x-=speed
} else if (char._x+range>enamy._x){
enamy.gotoAndStop(3)
}else if (char._x-range<enamy._x){
enamy.gotoAndStop(4)
}

```

some thing like this might work, or atlest is some where to start

(note; my speelchek is not working. supid MSword)
