How do I spawn actors at random locations but NOT near player

i’m not sure about what origin does, (the documentation about it is poor) but looks like if you set the player location as origin it will make the “position” be a value relative to the player position. try setting it to 0,0,0 and try again

PS.:1000 units can be a short distance depending on your game

PS.:your loop seems useless, the branch will only be called in the last element of the vector

I would like enemies to spawn at random locations around my map, but from a certain distance from the player so they spawn offscreen.

I tried making a condition where I exclude spawns that would happen within 1000 units to the player, but it doesn’t work. The enemies just keep appearing randomly everywhere, even right next to the player.

Hope someone can help, Thanks!

I’m not sure about the origin thing, but yeah the way I was getting the distance between the two locations was horribly wrong.

Here’s how I should’ve done it the first place.

I know, it’s a very old post, but I thought it might be worth to mention: The main cause for your trouble is the fact, that you are calling the GetRandomPoint actually twice - Blueprints are somewhat ‘dangerous’

First call happens with the comparison - this delivers the condition for the branch

Second call happens with the Spawn Node - input for the spawn location

The problem is, that using the output node from GetRandomPoint as input for spawn actually calls the GetRandomPoint function again, now delivering a value that might well be below 1000 again.

To solve this problem, a variable has to be used. First, this saves performance, and in cases like this, where previous nodes return random values, this even saves you from errors. For blueprint functions, local variables are best.

Here’s a quick example you might want to test:

Using the direct link will report vector length values below 1000, while using a variable to store values does the trick, simply by exchanging the connections.

Just another example: