Get Random point in radius does not work properly

I have described everything in this thread: "Get Random Point in Radius" creates very romantic hearts :P - Blueprint - Unreal Engine Forums

In 4.7.3 it actually are no hearts but other artifacts.

Btw, please include something like “Get Random Point in Square” (depending on navmesh), since for some applications I don’t need a circle but a square.

Hi

I was able to reproduce it as you described and entered a bug report for it (UE-12555). I did get different “patches” each time, so it was clearly not random enough. Also I got the empty patch in the same location, so it appears to have a “blind spot” right now.

Thanks for the report!

I saw some commits from a few weeks ago where he has fixed all the problems with random points, but this problem is still in 4.8, the random points are the same as in 4.7. So are the fixes for this not yet added to 4.8?

Apart from this, I have noticed we now have these three different nodes:

http://puu.sh/iliJG/ae63b74dc1.png

Where is the exact difference in these? If no nav data is specified they all work the same I suppose?

Hi

I am not sure why you would be seeing that, I’ve just ran a series of tests on the 4.8 version from the launcher (my personal one too just to make sure), but my random points are more evenly distributed now and lack the patchiness it had before. This was with a brand new project however and not a converted one. Can you give me some more details about what you’re seeing in 4.8 and if anything has changed at all?

For the new nodes, I’m working now to get better docs and information on how those work out to the public.

A quick breakdown:

Get Random Point in Radius is deprecated and it actually runs Get Random Reachable Point in Radius now, which functions the same way. (It was more of a name change for clarity)

Eventually it will be removed and replaced entirely.

Get Random Point in Navigable Radius is a bit different. If you have two or more nav meshes in a level and that are separated, then you can see how they work differently. You can see “Navigable” will return vectors on any nav mesh in the radius, while “Reachable” will only return vectors of the one closest nav mesh.

Please let me know if that helps!

Hi , thanks! Good to know that the old node is deprecated, I wonder why it is not marked as deprecated in 4.8?

I’m seeing this:

http://puu.sh/iqm9a/c648b9deba.png

Or with even more instances, this:

http://puu.sh/iqtdg/5ac74fac25.png

In comparison to 4.7 nothing has changed, looks exactly the same.

This is how I spawn the instances, same way as in 4.7:

http://puu.sh/iqm7z/43d909a4b1.png

Thanks so much for that setup information. Here’s what my blueprint test looks like (I took some liberties with the radius and loop values) and I think it’s really close:

I did this in a project I have been converting up since 4.5 just to see if it may be a conversion error and also a new 4.8 project. Oddly enough, my result was the same for both:

I did a Copy and Convert of my project into 4.8. What method did you use to bring your project into 4.8? “Convert in place”, “Copy and Convert” or “Skip Conversion”? I know it’s cliche, but does this also happen in a new 4.8 project? All that would help me know if it’s a problem with the project, the project conversion software or 4.8 itself.

A note about the deprecation: I looked into the code itself and it appears that it has comments all around it about deprecating it, but it was never fully done for no obvious reason. I’ve reached out to the AI team and pointed out the oversight for them to fix. Thanks!

Hi , thanks!

You are right, I tried it in a new 4.8 project and I did not get the problem there, the instances were distributed smoothly, although I used the same logic as in my real 4.8 project.

I converted my project to 4.8 using “Copy and Convert”.

I also noticed (in the new project) that I need to have a nav mesh bounds volume for the random function to work. If I have a navmesh bounds volume then the random function will also work outside of the navmesh bounds, but it’s radius is maxed to the size of the navmesh, which is a bit odd. So If my navmesh only has 500x500 size and I specify the radius of 1000, the radius is not 1000 but 500.

But in my real project the navmesh fills the whole landscape, so this is not a problem there.

I believe the necessity of a navmesh is a limitation to the Get Random Point’s functionality and thereby intended. The random vector is derived from the navmesh.

I think you may be seeing a discrepancy between world and local vectors. The “Add Instance” node is relative to the component and uses local space, while the get random point will return world space. Try changing the math to offset the location vector by the actor’s location. Like so:

Let me know if that fixes the random placement of meshes going off the navmesh.

I am not entirely sure what was lost in the copy and convert then, but I’m going to suggest you try right-clicking the project file and select “Switch Unreal Engine Version”. If you can set that manually to 4.8 and try running from there, we’ve seen that fix similar problems. Otherwise, I’ll see about helping you update those individual files associated with the random point generation.

Let me know if that helps!

Thanks!

I found what is causing the problem! I tried it with offset as you suggested and then the instances are spawned at the complete wrong location, but this showed me what the problem is:

The GetRandomPointInRadius function is getting a random point with the world location 0/0/0 being the center. And I have a building standing near the center which is affecting the navmesh, so there is no navmesh. So the missing instances I see are not there because at the world location there is a building:

http://puu.sh/irnz1/dd4456ee62.png

But why does the function pay attention to the navmesh if no NavData is specified? I thought it then acts as a function which just get’s a random point in a circle. I don’t need the nav data for this. If I would want to get a point on the navmesh I would specifiy the NavData input pin.

How can I make the function ignore the navmesh?

I just thought a bit about it and wondered why I am not just creating such a function myself:

http://puu.sh/iroZ0/50346c68d6.png

The random distrubution is not perfect with this, in the center are less instances than on the edge, but it works 100% without navmesh:

http://puu.sh/irpbL/ce96d89c45.png

I guess the “RandomUnitVector” node is just not made for something like this…

Aha! That would explain the hole, it was making the random points from that nav location near world origin. So it look like the local offset was involved, just not in the way I thought.

Glad that there was a work-around with the RandomUnitVector. You can probably tweak the output vector to more evenly distribute the meshes away from the edges.

Let me know if you need more help with this! Glad it wasn’t the bug coming back from the grave!

Cheers!