Getting Random Unit Vector in HALF Cone

Hi,

I’ve been recently struggling with creating inaccurate shooting system, and there’s one thing that I can’t figure out how to do. It’s about the RandomUnitVectorInConeInDegrees() node (using blueprints, but I’m familiar with C++). The problem is I need to get a random vector within the upper part of the cone only. I would illustrate it like this (the circle at the end of the cone):

251626-half-cone-random-vector.png


I think I could just use a while loop and each iteration check whether the randomly picked vector is above the center, but it would be really messy and costly.
Thanks in advance for any help!

In local coordinates of cone, top part will have +z, and bottom -z coord. values. So, I think, simplest way is to always make local z values absolute.

Now seems obvious to me. Thanks a lot!

After some time spent in C++ and trying to make my own function, I found a clean solution to my problem in blueprints. For those who are struggling with this problem: