Help on calculating crosshair spread w/ FOV?

I’m using UE4.27.

I’m struggling to calculate a value by which my crosshairs should expand. The end goal is that the crosshairs should encircle the weapon spread. At the moment, I have this:

FMath::DegreesToRadians((Weapon->GetSpread() * 0.5));

The weapon’s spread usually gives a value of 10-20 degrees. The code above gives me the radius of the weapon spread, but how do I convert this radius to a value that I can use to move the crosshairs? I’m assuming I would need to convert from the unit circle to screenspace.

Furthermore, how would I incorporate the camera’s FOV? By my estimation, the smaller the FOV, the larger the crosshair spread should be.

I found the solution, if anyone was looking:

viewportSize.X * 0.5f * Weapon->GetSpread() / FOV;

1 Like