Hi,
I’m trying to create a Heat Seeking Missile that follows the enemy, in my case and for test purposes ’ The Mouse '.
First of all i changed to transformation point to the center of my missile then its rotation to rotate toward the mouse, now i try to make follow the mouse, i’ve been reading about it in this tutorial:
But i guess i have a misconception between the AS3 rotate and the FlashPunk angle :
public function Missle(x:Number=0, y:Number=0, graphic:Graphic=null, mask:Mask=null)
{
_missile = new Image(MISSILE_ART);
mask = new Pixelmask(MISSILE_ART);
_missile.centerOO();
super(x, y, _missile, mask);
}
override public function update():void
{
var targetX:int = FP.world.mouseX;
var targetY:int = FP.world.mouseY;
_missile.angle = Math.atan2(targetY, targetX) * 180 / Math.PI;
var vx:Number = _speed * (90 - Math.abs(_missile.angle)) / 90;
var vy:Number;
if (_missile.angle < 0)
vy = -_speed + Math.abs(vx);//Going upwards.
else
vy = _speed - Math.abs(vx);//Going downwards.
x += vx;
y += vy;
super.update();
}
what do you guys think ?