RNG Without Repeating

So i am trying to make a system that my trees in the background spawns auto, i had a system like this


and it was working but there is a risk that 2 trees spawn at the same location, so how can i prevent that happens? I saw other peoples comments like “make an array add the random u got to the array and chech that number is in already in array and continue” i got the point but i failed to implement it to my system, can someone make it and show me please or write which nodes to put where, thank you.

If I got the right idea:.

  • loop and add current index value to the min/max rand value.

??

Can you show it in blueprint please, with just simple variables with no names would be fine.

What should i do from this part?

I’ll edit with a bp later when at pc.

1 Like

Hey man, did you forgot it?

I also changed the system a bit

Try this:

1 Like

That works! Can you explain why we need a half widght? And also i have 1 small problem the trees spawn but from right to left how can i change this to left to right? Also when i change the offset a value bigger than 500 some of the trees spawn inside of each other

It’s to offset the location so the assets are distributed evenly on both sides of the relative (0.0, 0.0, 0.0). Not really necesarry If you don’t mind the distribution starts from the actors pivot.

Change the loop to iterate towards 0 or use (InCount - 1) - index to ‘invert’ the count.

The offset should be lower than half the tile width to keep each assets in their respective tile.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.