Ok so I am doing a turret defense game but I need my turret to only move up and down to a certain point. I have this code:
onClipEvent (enterFrame) {
myRadians = Math.atan2(_root._ymouse-this._y, _root._xmouse-this._x);
myDegrees = Math.round((myRadians*180/Math.PI));
_root.yChange = Math.round(_root._ymouse-this._y);
_root.xChange = Math.round(_root._xmouse-this._x);
_root.yMove = Math.round(_root.yChange/20);
_root.xMove = Math.round(_root.xChange/20);
this._rotation = myDegrees+90;
}
The problem is it rotates I need it only to move up and down to a certain point. Kind of like heli invasion. But I was thinking I should only use a code that uses the Y axis but I have no clue. Anyone want to steer me in the right direction?