The direction is working, but if my pointer (mouse) is near the player, it will launch the projectile slowly. And if the mouse is far from the player, the projectile is super fast.
Is there a way to get the direction without having this problem?
You could try creating a Vector3 with the direction and normalizing it and then multiplying that with the speed you wanted, I havent tested this code but something like this should work:
Vector3 shotDir;
float shotSpeed=100f; //Change this with whatever value you want
Obviously this is just pseudo code so you’d have to change all that mousepos.x and player.x for the actual Vector3 containing the mouse and player position but I think that should work, also if the bullet are coming backwards maybe you’d want to try doing player - mouse instead of mouse - player when calculating the direction