firing a bullet

Currently i'm using this code to fire a bullet towards my mouse:
Code:
diffX = stage.mouseX - (map2D.player.playerBox.x + map2D.x);
diffY = stage.mouseY - (map2D.player.playerBox.y + map2D.y);
         
var direction:b2Vec2 = new b2Vec2(diffX / MapBox2D.RATIO, diffY/ MapBox2D.RATIO);
direction.Normalize();
         
bulletBody.ApplyImpulse(direction, map2D.player.playerBody.GetPosition());


This kinda works good, but the bullet is moving way to slow, is there a way of speeding it up?
How about not normalizing the vector or multiplying that vector you enter in the impulse function?, since the vector you give in is not only the direction but also the force you give, so lets say its 1,1 it inputs a force of 1,1.

So multiply that vector by 2 and your force is 2,2 and so on.
Thanks, that worked great

But now i'm calculation that the bullet should fire towards my mouse, but in reality it should fire from a gun that the player is holding.
I know the rotation of the gun, but i have no idea how to calculate that direction the bullet should fly in.

Right now i'm doing it this way:
Code:
diffX = stage.mouseX - (map2D.player.playerBox.x + map2D.x);
diffY = stage.mouseY - (map2D.player.playerBox.y + map2D.y);

var direction:b2Vec2 = new b2Vec2(diffX / MapBox2D.RATIO, diffY/ MapBox2D.RATIO);
direction.Normalize();
direction.Multiply(2);
         
bulletBody.ApplyImpulse(direction, map2D.player.playerBody.GetPosition());
so you want to calculate from angle, into X/Y unit vector?

//find unit vector of rotation.
var uvec //could be Point, or b2Vec2 or V2. your choice
uvec.y = Math.cos(rot * Math.PI/180);
uvec.x = Math.sin(rot * Math.PI/180);

honestly, I'm pretty sure cos is supposed to be X and sin is supposed to be Y, i probably am calculating for a 90º art rotation from what 0º would normally be.

hope this helps.
I'm no expert at maths but the easiest way should be:

Code:
mXDir=Math.cos(Angle*Math.PI/180);
mYDir=Math.sin(Angle*Math.PI/180);

var direction:b2Vec2 = new b2Vec2(mXDir / MapBox2D.RATIO, mYDir / MapBox2D.RATIO);
direction.Multiply(2);

bulletBody.ApplyImpulse(direction, map2D.player.playerBody.GetPosition());


Keep in mind that the xdir and ydir are values between 0 and 1;

Original thread: https://box2d.org/forum/viewtopic.php?t=5045