No horizontal bullet spread when looking up or down

I have a blueprint that spawns projectiles with a random bullet spread in front of the player, here is my blueprint:

As you can see, I spawn a projectile in front of the gun barrel, and then add a random float in range to the rotation offset, the problem is that if I look at the ground, or at the sky, the horizontal spread is 0. I am guessing that this has something to do with world rotation rather than local rotation. Applying any sort of Roll does not make a difference in the output.

Here is an example of my bullet spread:

Welcome to the world of Gimbal Lock! The issue is that your code is fine, BUT it returns values that exceed 360 degrees/goes under 0 degrees(or in the case of pitch, over 90/less than -90), which sounds all fine and dandy until the engine clamps those values to 0/360 and -90/90 respectively(which is a good thing).

In order to resolve this, you need to make a rotation for just your random values, convert this new rotation into a vector using GetRotationXVector, rotate this vector by the aim rotation, and then use GetRotationFromXVector once more. The output is your new, non-gimbal-locked rotation.

Thankyou, you are a life saver!

Currently trying to recreate you blueprint in c++.
What is that with “Inputs” specifically with the angle part? where does that come from?

It’s clearly the angle through which the projectile is deviating from the aim direction.