# Random movement and "move to spot" trouble

**URL:** https://forum.kirupa.com/t/random-movement-and-move-to-spot-trouble/246101
**Category:** Uncategorized
**Created:** [December 7, 2007, 1:02am UTC](https://forum.kirupa.com/t/random-movement-and-move-to-spot-trouble/246101 "2007-12-07T01:02:48Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![zach93111](https://avatars.discourse-cdn.com/v4/letter/z/e0b2c6/32.png) [@zach93111](https://forum.kirupa.com/u/zach93111)
#### Post date: [December 7, 2007, 1:02am UTC](https://forum.kirupa.com/t/random-movement-and-move-to-spot-trouble/246101/1 "2007-12-07T01:02:48Z")

</div>

This script is supposed to refresh mine location by deleting older mines and shooting new ones every 25 seconds or so. But for some reason after the 3rd mine, the mines don’t move at all… I’m sure its a small script issue but…I don’t see it…

btw.  
\_root.faceMe is the enemy…

```auto

for (h=0; h<2; h++) {
            turret4 = _root["turret4"+h];
            mineTime++;
            if (mineTime>=25) {
                mineTime = 0;
                mine = attachMovie("mine", "mine_"+_root.getNextHighestDepth(), _root.getNextHighestDepth(), {_x:turret4._x, _y:turret4._y});
                mineCount++;
                mine._rotation = 0+Math.random()*360;
                mine.swapDepths(turret3);
                mine.swapDepths(turret2);
                mine.swapDepths(turret1);
                trace(mineCount);
                mine.onEnterFrame = function() {
                    xspeed4 = speed4*Math.sin(this._rotation*(Math.PI/180));
                    yspeed4 = speed4*Math.cos(this._rotation*(Math.PI/180))*-1;
                    this._x += xspeed4;
                    this._y += yspeed4;
                    speed4 -= .3;
                    if (speed4<=0) {
                        speed4 = 0;
                    }
                    if (this._x>550 || this._x<0 || this._y>400 || this._y<0) {
                        unloadMovie(this);
                    }
                    distance4 = 150;
                    if (Math.sqrt((this._x-turret4._x)*(this._x-turret4._x)+(this._y-turret4._y)*(this._y-turret4._y))>distance4) {
                        unloadMovie(this);
                    }
                    if (this.hitTest(_root.faceMe)) {
                        unloadMovie(this);
                        attachMovie("explosion", "explosion_"+_root.getNextHighestDepth(), _root.getNextHighestDepth(), {_x:this._x, _y:this._y});
                    }
                };
            }
        }

```
