# Following code

**URL:** <https://forum.kirupa.com/t/following-code/264150>\
**Category:** programming\
**Created:** [June 23, 2008, 3:55pm UTC](https://forum.kirupa.com/t/following-code/264150 "2008-06-23T15:55:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lancerawks](https://avatars.discourse-cdn.com/v4/letter/l/4da419/32.png) [@lancerawks](https://forum.kirupa.com/u/lancerawks)\
**Post date:** [June 23, 2008, 3:55pm UTC](https://forum.kirupa.com/t/following-code/264150/1 "2008-06-23T15:55:52Z")

</div>

hey, in my game i want the \_parent movie clip to follow the fish movie clip. i used this code i made… but the following is realy jerky and dosnt look nice. are there any other ways of doing it so that the closer you get the faster the follower accelerates towards you?

```auto
disx = Math.abs(_parent._x - _root.fish._x)
 disy = Math.abs(_parent._y - _root.fish._y)
 if(_parent._x > _root.fish._x){_parent._x -= _root.speed/disx}
 if(_parent._x < _root.fish._x){_parent._x += _root.speed/disx}
 if(_parent._y < _root.fish._y){_parent._y += _root.speed/disy}
 if(_parent._y > _root.fish._y){_parent._y -= _root.speed/disy}

```

---

<div class="post-metadata">

**Author:** ![lkky00245](https://avatars.discourse-cdn.com/v4/letter/l/d78d45/32.png) [@lkky00245](https://forum.kirupa.com/u/lkky00245)\
**Post date:** [June 23, 2008, 4:39pm UTC](https://forum.kirupa.com/t/following-code/264150/2 "2008-06-23T16:39:21Z")

</div>

If games like usfine sell [buy wow goldQuake and Doom defined action gaming in the gaming world, Need for Speed was the definition of racing games. Need For Speed, [url=http://www.usfine.com/Maple-Story-PowerLeveling-c-98.html]maple story power levelingor NFS for short has been around since almost the beginning of when computer gaming gained importance. [url=http://www.usfine.com/runescape-powerleveling-c-90.html]runescape power levelingNeed For Speed is [url=http://www.usfine.com/runescape-powerleveling-c-90.html]runescape powerleveling a racing game in which the player chooses cars and then races on various tracks. It was and is highly playable due to the simplicity of controls and existence of a thin progressive knack in the game. [url=http://www.usfine.com/runescape-powerleveling-c-90.html]runescape](http://www.usfine.com/world-of-warcraft-usa-c-51.html)

---

<div class="post-metadata">

**Author:** ![randomagain](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@randomagain](https://forum.kirupa.com/u/randomagain)\
**Post date:** [June 23, 2008, 6:42pm UTC](https://forum.kirupa.com/t/following-code/264150/3 "2008-06-23T18:42:58Z")

</div>

there are various examples and tuts on this issue I suggest you search the forum and google the web

---

<div class="post-metadata">

**Author:** ![rrh](https://avatars.discourse-cdn.com/v4/letter/r/67e7ee/32.png) [@rrh](https://forum.kirupa.com/u/rrh)\
**Post date:** [June 23, 2008, 6:48pm UTC](https://forum.kirupa.com/t/following-code/264150/4 "2008-06-23T18:48:48Z")

</div>

Maybe some trig will help you find something more to your liking.

Also take a look at Hooke’s law, which is an elasticity formula.

---

<div class="post-metadata">

**Author:** ![lancerawks](https://avatars.discourse-cdn.com/v4/letter/l/4da419/32.png) [@lancerawks](https://forum.kirupa.com/u/lancerawks)\
**Post date:** [June 23, 2008, 8:15pm UTC](https://forum.kirupa.com/t/following-code/264150/5 "2008-06-23T20:15:47Z")

</div>

hookes law… i think i learnt that in school… i cant remember thanks ill look into it
