# Problem with rotating shot

**URL:** https://forum.kirupa.com/t/problem-with-rotating-shot/322492
**Category:** Uncategorized
**Created:** [May 23, 2011, 12:46pm UTC](https://forum.kirupa.com/t/problem-with-rotating-shot/322492 "2011-05-23T12:46:33Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![DAINO](https://avatars.discourse-cdn.com/v4/letter/d/2acd7d/32.png) [@DAINO](https://forum.kirupa.com/u/DAINO)
#### Post date: [May 23, 2011, 12:46pm UTC](https://forum.kirupa.com/t/problem-with-rotating-shot/322492/1 "2011-05-23T12:46:33Z")

</div>

hello,

i have a problem in rotating the shot of the enemy (there are some).

I elaborated on the problem﻿.

i have my class of the enemy. i have the class for his shot. and some lines on the TimeLine.

i need to do that every enemy will have is own shot rotation. and when i checked with the trace command happen what i wanted to happen (evey enemy have is own rotation of shot)… but its not work.

this is the code on the timeLine:

```auto
var enemy:MovieClip;
var enemyArray:Array = [];
 
enemySpawn = function(numEnemies){
    for(i=1;i<=numEnemies;i++){
        enemy = attachMovie("enemy", "enemy"+i, i);
        enemy1._x = 939;
        enemy1._y = 299;
        enemy2._x = 619;
        enemy2._y = 278;
        enemyArray.push(enemy);
    }
}
enemySpawn(2);

```

this is the code of the class of the shot of the enemy:

```auto
class ShotEN extends MovieClip
{
    var i:Number;
    var enemyArray:Array;
    var radians:Number;
    var speed:Number;
    var ang:Number;
    var xSpeed:Number;
    var ySpeed:Number;
 
    function onLoad(){
        enemyArray = _root.enemyArray;
        radians = Math.PI/180;
        speed = 25;
        for(i = 0; i < enemyArray.length; i++){
            trace(enemyArray*);
            trace(enemyArray*.numToRot);
            ang = (enemyArray*.gun._rotation - enemyArray*.numToRot)*radians; //look at this line i think in this the main problem
            xSpeed = Math.cos(ang)*speed;
            ySpeed = Math.sin(ang)*speed;
            this._y = enemyArray*._y -10;
        }
    }
 
    function onEnterFrame(){
        _x += xSpeed;
        _y += ySpeed;
    }
}

```

and in the class of the enemy i do a Variable﻿ called “numToRot” and do that when the enemy pos is right the value of the variable is 0 and when its left its -180. so when the enemy turn left the shot too.

i hope you understand me.

Thanks to everyone who helps﻿!﻿
