# Basic AI - Side scrolling game

**URL:** <https://forum.kirupa.com/t/basic-ai-side-scrolling-game/228091>\
**Category:** programming\
**Created:** [June 5, 2007, 10:17am UTC](https://forum.kirupa.com/t/basic-ai-side-scrolling-game/228091 "2007-06-05T10:17:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ElmosGotAGun](https://avatars.discourse-cdn.com/v4/letter/e/e8c25b/32.png) [@ElmosGotAGun](https://forum.kirupa.com/u/ElmosGotAGun)\
**Post date:** [June 5, 2007, 10:17am UTC](https://forum.kirupa.com/t/basic-ai-side-scrolling-game/228091/1 "2007-06-05T10:17:42Z")

</div>

Hey I’m having a bit of trouble with getting the AI to work with my side scrolling game i have an enemy and a player char that you can control, on the enemy i have:

```auto
onClipEvent (load) {
speed = 5;
}
onClipEvent (enterFrame) {
if (this._x > _root.player._x+speed) {
this._x-=speed;
} else if (this._x < _root.player._x-speed) {
this._x+=speed;
}
}

```

but when move right so the image scrolls it doesnt seem to follow the player anymore.

if anyone can help me add me on msn, i can send u my fla if need be  
MSN: [sachmojo277@hotmail.com](mailto:sachmojo277@hotmail.com)
