I am currently working on a gun and I want my bullet to fly at the same speed no matter where I aim.
Everything was working fine until I decided to switch from CameraLookVector to mouse.hit.Position. I noticed that when my mouse is on nothing, the ball goes crazy fast, but when it’s on the ground, it goes much slower.
I searched the internet for possible solutions, but somehow I couldn’t find anything good. I also tried changing from Velocity to AssemblyLinearVelocity, but that didn’t solve the problem either.
I printed the velocity of the bullet after firing upwards, forwards, to the left and finally on the ground. Here are the results:
Upwards: 1698.26123046875, 99905.703125, -2564.900390625
Forwards: -6379.9912109375, 11289.669921875, -99045.21875
Left: -99583.421875, 7948.52734375, 2958.54931640625
On the ground: -21.400535583496094, -45.31282424926758, -3.292813301086426
As you can see, the speed is lower when the object to be hit is closer.
This is the part where I apply speed to the part:
Lauf is the part on the front of the weapon
local direction = mouse.Hit.Position - Lauf.Position
BulletPart_FRONT_10mmClone.Velocity = direction * 10
How can I fix this problem so that my projectile always flies at the same speed?