# Making "smooth moving homing" ball

**URL:** <https://forum.kirupa.com/t/making-smooth-moving-homing-ball/227420>\
**Category:** Uncategorized\
**Created:** [May 30, 2007, 5:32am UTC](https://forum.kirupa.com/t/making-smooth-moving-homing-ball/227420 "2007-05-30T05:32:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mentega](https://avatars.discourse-cdn.com/v4/letter/m/57b2e6/32.png) [@mentega](https://forum.kirupa.com/u/mentega)\
**Post date:** [May 30, 2007, 5:32am UTC](https://forum.kirupa.com/t/making-smooth-moving-homing-ball/227420/1 "2007-05-30T05:32:57Z")

</div>

well im not sure if this is enough to be called an a.i 😛 but what im trying to do is getting a code that home in on a player and hopefully that code can be used on a missile or some sort \>.\< but because the way the code works it bounces like a ball which i think it’s not good for a missile to move like that 😛

im trying to use Point but it compiles error saying it cannot load the class ☹

i’m kinda noob in programming ^\_^" so can anyone lend me a help and suggest me with a better way of making something like this?

here is what i can come out with  
all it can do is to track X and Y then either + or - them ☹

```auto
tracker.onEnterFrame = function() {
// getting positions
var myY = tracker._y
var playerY = _root.my._y
var myX = tracker._x
var playerX = _root.my._x
if (myY != playerY){
 if(myY > playerY){
  this._y -= 20
  trace("-y")
 }else if (myY < playerY){
  this._y += 20
  trace("+y")
 }
}
if (myX != playerX){
 if(myX > playerX){
  this._x -= 20
  trace("-x")
 }else if (myX < playerX){
  this._x += 20
  trace("+x")
 }
}
 
};

```
