How to make bullet hit where cross hair is pointed (Better explanation in thread)

Hi, I have a gun prototype that spawns it’s bullet in front of it’s barrel. Of course since it’s not originating from the center of the screen simply translating it with Vector3.forward wouldn’t land the bullet where the player was aiming.
I already came across the idea of simply raycasting a ray from the center of the camera and using the hit position to find the direction for the bullet to go in. But then when you get really close to an object, it becomes pretty obvious that the bullet isn’t traveling straight out of the barrel. (Slow bullet speeds in my game)
Is there a way to get around this? I did a bit of thinking and realized that Valve managed to get around the issue with the rocket launcher for Soldier in TF2. So there has to be a way, right?

Hi!

From my point it looks like you did everything right, but one small piece is missing. When doing raycast, calculate the hit point keeping minimal hit distance. Then shoot right out of gun’s barrel and move the bullet directly to the calculated hit point. It should look as desired now.