Bullet direction innaccurate

Im raycasting to get the position the camera is looking at, then getting the direction between the bullets origin and the hit position.

local origin = ArmaClone.SmokePart.CFrame
aimCast = WS:Raycast(Camera.CFrame.Position, Camera.CFrame.LookVector * 500000, rayparams)

if aimCast then
	Direction = (aimCast.Position - origin.Position).Unit
end

This works fine from longer distances but when you get closer the direction of the bullet goes is way off:


So you mean like: The bullet markers should be inside the ironsight in that one picture, but they are above?

I see you are calling it ArmaClone, so I should ask if the raycast start position is based on the position of the end of the barrel of the gun.


Also, would it be that you meant to do this maybe: ?

Direction = (aimCast.Position - Camera.CFrame.Position).Unit

I’m not sure what “SmokePart” is. So I could be wrong on this.


But like I said first, In Arma, bullet literaly start at the gun. So when you are “aiming”, you are pointing the camera around. But the raycast that would fire would start at a position right in front of the barrel, and point “forward” from the gun. Rather than the ray starting at the camera.
This would also mean that aiming down sight would give you the right direction, because the ray is “lined up” with the camera, more or less.

Also, due to this difference in how the raycast is used. It would be helpful in hipfire mode to have a crosshair that can freely move around based on where the gun is aiming. So the crosshair could be anywhere on screen, not just in the center. But it would then give you an accurate depiction of where your bullets end up.