Infinite Random Floating Islands Generator

Ok. I made a little random island thing:

island

Just something for me to work with :slight_smile:

The main part is the box that follows the player. It’s just a collision box that I can scale:

On begin play, I wait a moment until I know where the player is and spawn my little islands randomly in the box

Then, on tick, the box moves with the player.

I have to check each tick if any of the islands are outside the box. If they are, I just move them to the opposite side / edge. It’s a trick I saw with particle systems.

You might want to kill them and spawn a new one in the new location, it’s up to you. The player might start to recognize islands. Optimizations include doing this on a timer ( not tick ) etc.

The relocation code looks like a total nightmare, but it’s actually not. All it does is take the XY location and correct it to the other side of the box if it’s out of bounds. Brace yourself:

Here, I’m making it deliberately obvious what’s happening:

obvious

And now, not so obvious, with a larger box:

notso obvious

It’s starting to ‘chug’ a little now. I have 250 islands. Very much a work in progress…

This is 1200 islands and twice the box size. I put the process on a timer, maybe you can see the frame rate hit once per second ( top right )

1200

1 Like