Most games raycast from infront of their gun’s muzzle if I understand correctly but if you dothat the bullet wont hit the crosshair so how do I raycast from the gun muzzle but also make it aim towards the crosshair.
I am looking for : the bullet to look like it comes from the gun and not the camera but also hits the crosshair.
Raycast from the cross hairs. Muzzle flash on the gun. Forget the actual bullet. Its about faking it, not getting it right.
To actually get it right you would need to raycast from the crosshairs to a world position, then get the direction from your gun muzzle to that world position. Then raycast from your gun muzzle. This will make some very unusual effects when the target is really close.
A bullet moving at 1200 meters per second will travel 20 meters in one frame (@60fps). A 5.56 mm bullet at 20 units is barely a speck. No one is going to notice that it came from a foot to the left of the muzzle.
And that’s if you even bother with a ballistics simulation, instead of just a hitscan weapon