How to spawn an actor outside a defined radius?

I’m trying to make a random npc spawner. I’m using the Spawn AI from class node to spawn an NPC and in the location I use the node “get random point in navigable radius” then select the player’s location as the origin. But I want to prevent npcs from spawning directly in front of you. How can I get a random point outside a specific radius and inside another? so that NPCs spawn arround the player, but not directly in front. Thanks.

Could you clarify:

NPCs spawn arround the player

prevent npcs from spawning directly in front of you

Is this supposed to be a specific shape the enemies spawn in?


If you simply want them spawn behind you, place the origin behind the player:

Image from Gyazo

so your looking for something like spawn a enemy 500-1000 units from the player and behind them. so if it were a shape it would be like a half ring. i think Everynone’s answer would be easiest otherwise you will have to do a lot more math and checks or come up with a good formula.

Yes, I want the npc to spawn arround
the player but at a minimum distance.
(I don’t mind them spawning in front
of the player. I just want them to
spawn at a minimun distance from the
player.) Right now with the random
point in radius, the spawn area is
basically a circle, I want it to be a
ring, like you mentioned.

Here’s a ring with a front cut out. This is a brute force approach with a smidgen of math, it rejects points that are outside of the frontal cone (controlled by a variable) and are too close.

You’d need to run this in a limited loop, just in case no points can be found. Or iterate X times and utilise valid results only.

Image from Gyazo


Apart from that I never really looked too deep into how nav data works in UE4, I know you can build differently shaped brushes, including hollow ones:

Perhaps there is a way to combine shapes and use the result, that would eliminate the need for brute-forcing it.

1 Like

Yes, I want the npc to spawn arround the player but at a minimum distance. (I don’t mind them spawning in front of the player. I just want them to spawn at a minimun distance from the player.)
Right now with the random point in radius, the spawn area is basically a circle, I want it to be a ring, like you mentioned.

Thanks, I’ll use this solution for now.

I made a tutorial for this. The tutorial explains about how to get points in a donut shape/ hollow circle. But you can use this just by increasing the Radius of the outer circle.
Link: Get Random points in Donut /Hollow Ring in Unreal Engine (With and without EQS) - YouTube

1 Like

This really helped a lot thanks!