Hi guys,
I have the following code where Projectiles are guided toward the ship.
DeltaX = (_ShipPosX + _Ship.Width / 2) - Projectile.PositionX;
DeltaY = (_ShipPosY + _Ship.Height / 2) - Projectile.PositionY;
Angle = Math.Atan2(DeltaY, DeltaX) * 180 / Math.PI;
Projectile.SetPosition(Projectile.PositionX += Math.Cos(Angle) * General.MonsterProjectileSpeed, Projectile.PositionY += Math.Sin(Angle) * General.MonsterProjectileSpeed);
It is fine when the ship doesn't move but when the ship starts to move, the projectile is rotating around itself. I'm wondering what I'm missing to make the projectile continue its course. I tried to figure this out since a week or two now without success. I was hoping someone could shed some light on it.
You can see the effect here : https://skydrive.live.com/redir?resid=7056CFFE05236B7D!919&authkey=!AF1Ef24BdnDgYT4&ithint=video%2c.mp4
Thank you for any help.