# How do u make a enemy follow your character?

**URL:** https://forum.kirupa.com/t/how-do-u-make-a-enemy-follow-your-character/262990
**Category:** Uncategorized
**Created:** [June 11, 2008, 5:26pm UTC](https://forum.kirupa.com/t/how-do-u-make-a-enemy-follow-your-character/262990 "2008-06-11T17:26:12Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![topshotaz](https://avatars.discourse-cdn.com/v4/letter/t/3e96dc/32.png) [@topshotaz](https://forum.kirupa.com/u/topshotaz)
#### Post date: [June 11, 2008, 5:26pm UTC](https://forum.kirupa.com/t/how-do-u-make-a-enemy-follow-your-character/262990/1 "2008-06-11T17:26:12Z")

</div>

hey I’m kind of new 2 AS3, I’m working on this game for my project and I’ve been looking all over on for tutorials on how to make a enemy chase after your character. Can someone help me with this problem please , it’s driving me nuts…lol:sen:

---

<div class="post-metadata">

### Author: ![DiamondDog](https://avatars.discourse-cdn.com/v4/letter/d/74df32/32.png) [@DiamondDog](https://forum.kirupa.com/u/DiamondDog)
#### Post date: [June 11, 2008, 6:56pm UTC](https://forum.kirupa.com/t/how-do-u-make-a-enemy-follow-your-character/262990/2 "2008-06-11T18:56:11Z")

</div>

If all you want is to have some ‘Enemy’ movie clip follow a ‘Character’ movie clip you could do it with an event listener like this

```auto
// add an event listener to your Enemy movie clip
myEnemy.addEventListener(Event.ENTER_FRAME, follow);

// define how close you want the Enemy to be
var offsetX:int = 50;
var offsetY:int = 10;

// then have a 'follow' function which will get called every 
// frame because of the event listener

function follow(e:Event):void
{
    // all it does is set the Enemy's coordinates
    myEnemy.x = myCharacter.x - offsetX;
    myEnemy.y = myCharacter.y - offsetY;
}

```

No doubt there’s tons more to your game than just that (like, how are you moving your character movieclip?) but maybe it’s a start.
