# Bullet speed changes depending on how close and far I click the mouse button

Hi All,
First of all I would like to apologize for my bad English, please bear with it.

So I have been working on a 2D Top Down space shooting game, where my space ship looks and moves in the direction of my mouse position.
I somehow manage to work it out, but I’m facing some problems with it.
When I shoot with my mouse away from my space ship the bullet goes faster, on the other hand when I shoot with my mouse very close to my space ship the bullet travels very slowly
Here is my script for shooting

void Shoot () {

Vector3 shootDirection;
shootDirection = Input.mousePosition;
shootDirection.z = 0.0f;
shootDirection = Camera.main.ScreenToWorldPoint (shootDirection);
shootDirection = shootDirection - transform.position;

Rigidbody2D bulletInstance = Instantiate(bulletPrefab, firePoint.position, firePoint.rotation) as Rigidbody2D;
bulletInstance.velocity = new Vector2 (shootDirection.x * bulletSpeed, shootDirection.y * bulletSpeed);
}

The problem is you are not normalizing the shootDirection after calculating. So the magnitude of the shootDirection vector depends on the distance between transform.position and the world mousePosition if you dont normalize it. Try this:

void Shoot () {

Vector3 shootDirection;
shootDirection = Input.mousePosition;
shootDirection.z = 0.0f;
shootDirection = Camera.main.ScreenToWorldPoint (shootDirection);
shootDirection = shootDirection - transform.position;
// normalize it so that no matter how far you have clicked the magnitude does not depend on the distance
shootDirection = shootDirection.normalized;

Rigidbody2D bulletInstance = Instantiate(bulletPrefab, firePoint.position, firePoint.rotation) as Rigidbody2D;
bulletInstance.velocity = new Vector2 (shootDirection.x * bulletSpeed, shootDirection.y * bulletSpeed);
}

A very BIG thanks to OG23… The issue is solved. Here is the final script which did the job

void Shoot () {

Vector3 shootDirection;
shootDirection = Input.mousePosition;
shootDirection.z = 0.0f;
shootDirection = Camera.main.ScreenToWorldPoint (shootDirection);
shootDirection = shootDirection - transform.position;

//shootDirection = shootDirection.normalized;

Rigidbody2D bulletInstance = Instantiate(bulletPrefab, firePoint.position, firePoint.rotation) as Rigidbody2D;

bulletInstance.velocity = new Vector2 (shootDirection.x, shootDirection.y).normalized * bulletSpeed;

}