hay guys
i'm trying to make a bullet to keep moving towards the mouse position and keep moving till it crosses the screen or hit an enemy. i dont want it to stop at the mouse position when it reach it.
the problem is the bullet travels from the player to the mouse position and when it reaches the mouse position is stops and if i move the mouse the bullet keeps following the mouse, which is not what i want.
here is the code can you guys please help
here is a site that does exactly what i want check it out
http://www.benoitfreslon.com/actionscript-throw-bullets-to-mouse-direction
float Speed = 10;
float BulletX = Sprite[i].GetPosition().x;
float BulletY = Sprite[i].GetPosition().y;
float AngleX = MouseX - BulletX;
float AngleY = MouseY - BulletY;
float vectorLength = sqrt(AngleX*AngleX + AngleY*AngleY);
float DirectionX = AngleX / vectorLength;
float DirectionY = AngleY / vectorLength;
float VelocityX = DirectionX * Speed;
float VelocityY = DirectionY * Speed;
Sprite[i].Move (VelocityX, VelocityY);