How to get a random point in a hollow circle

284999-tim图片20190814141515.png

Like in this image,player is the red point,and I want to get random point in black area.

Idk about c++, but with blueprints you would take the random unit vector node and multiply the by the radius of your circle. Could use the random float in range node for the radius to control the width of the circle.

Can you post a picture about the blueprint you talk?I’m not familiar with blueprint

Here the c++ version:

3D : 
auto result = FMath::VRand(); 
result *= FMath::RandRange(BlackAreaInnerRadius,BlackAreaOuterRaduis);

2D : 
auto result = FVector2D(FMath::VRand()); 
result.Normalize();
result *= FMath::RandRange(BlackAreaInnerRadius,BlackAreaOuterRaduis);

you would need to add the player location to the result obviously

1 Like

Here is a possible Blueprint solution:

For some reason it always gives a random location even if i dont attach "random float in range

I made a whole tutorial just for you:
Get Random points in Donut /Hollow Ring in Unreal Engine (With and without EQS) - YouTube

2 Likes


I revise the BP so that the AI ​​to go behind to the player