# How to stop my motion

**URL:** <https://forum.kirupa.com/t/how-to-stop-my-motion/256796>\
**Category:** Uncategorized\
**Created:** [April 7, 2008, 2:19pm UTC](https://forum.kirupa.com/t/how-to-stop-my-motion/256796 "2008-04-07T14:19:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![samuk](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@samuk](https://forum.kirupa.com/u/samuk)\
**Post date:** [April 7, 2008, 2:19pm UTC](https://forum.kirupa.com/t/how-to-stop-my-motion/256796/1 "2008-04-07T14:19:38Z")

</div>

Hi, i have a fish that follows the mouse position.  
Im working out the angle and distance it is from the mouse cursor and telling it to swim in that direction. But when he gets there he flickers back and forwards.  
How can i get him to rest/settle at the position until the mouse is moved again.

```php
 speed = 4;
 fishy = attachMovie("fishy", "fishy", 0);
 fishy._x = Stage.width / 2;
 fishy._y = Stage.height / 2;
function onEnterFrame(Void):Void
{
 var dx:Number = _xmouse - fishy._x;
 var dy:Number = _ymouse - fishy._y;
 var angle:Number = Math.atan2(dy, dx);
 var dist =Math.sqrt(dx*dx+dy*dy);
 
 fishy._rotation = angle * 180 / Math.PI;
 var vx:Number = Math.cos(angle) * speed;
 var vy:Number = Math.sin(angle) * speed;
 fishy._x += vx;
 fishy._y += vy;
 if(dist <= 1){
  fishy._x += 0;
  fishy._y += 0;
 }
}

```
