Projectile speed changing by distance to target

I don’t know why this is being such a pain but I cannot seem to get it working correctly.

I am in a 2d project, I have my player object in the bottom left corner of the camera view. I am taking click input from the mouse to fire a projectile at the mouse position. The aiming works fine, the problem I am having is that the speed of the projectile object is changing based on the distance of the click from the start point.

I am taking the mouse input, running ScreenToWorldPoint on it, subtracting the result from the player’s transform.position (player.transform.position - Camera.main.ScreenToWorldPoint(inputPos)) and passing the normalized result to the projectile and letting it transform.translate(targetPos * projectileSpeed * Time.deltaTime)

It all works as I would expect EXCEPT for the difference in speed. If you click very close to the player’s position the projectile moves VERY slowly.

PLEASE!! What am I doing wrong? Or not doing that I need to be?

THANKS!

Posting your script would help with give an accurate answer, but the issue is that you are not normalizing the targetPos vector. The code should be something like this:

targetPos = (player.transform.position - Camera.main.ScreenToWorldPoint(inputPos)).normalized;

Note the ‘normalized’ on the end. You could do in your translate call instead:

transform.translate(targetPos.normalzied * projectileSpeed * Time.deltaTime);

Note that your ‘projectileSpeed’ will likely need to be increased.