Infinite Random Floating Islands Generator

I wanna scatter floating islands in the sky infinitely by seed. HOW? WHERE ARE THE TUTORIALS?

I did this. Here’s a level from my game:

Only 7 of the islands are made by hand ( the ones you actually land on ), all the rest are randomly chosen and placed.

It is also possible to make randomly generated islands good enough to walk on. It really depends on your needs.

What I did in this case, was to make ( by hand ), 5 different variations of island for the distance. I then used blueprint to place them all over the sky around the ‘real’ ones.

The whole thing revolves around making a random unit vector and multiplying it by a random float in the range ‘far enough away’ → ‘not too far away’.

If you’re interested in the setup, I’ll can drop a bit of code in…

1 Like

I would love to see your setup. I’m using voxelplugin for generating island but there’s none tutorials for procedural infinite spawn objects. I’ve exposed seed and scale from island for blueprint.

So, islands in the sky 101 is:

Almost immediately, it becomes apparent, that because the process is random, you sometimes get overlapping objects.

To avoid that, I kept an array of locations placed so far, and checked against that with a distance.

Is this the kind of thing you mean?

It may also suit you better to use RandomPointInBoundingBox. It really depends where you’re heading…

1 Like

If I crank it up to a ridiculous level, you can see they’re appearing in a sphere shape, with a ‘safe zone’ in the center:

islandsphere

1 Like

Thank you for your code snippet. It’s good for procedural population for level. Can I somehow turn this into a procedural generator? The player can travel in an infinite direction and islands will be generated, and they will depend on the seed.

That’s a bit more of a fiddle, but totally possible.

Basically you have a box ( or sphere etc ) following the player. The size of the box is the area around the player you want populated.

As the player moves forward ( for example ), the islands that have left the box are killed and new islands are spawned on the forward edge ( just out of player view distance ).

Do you get what I mean?

I can do a bit of code later. Performance will become an issue depending on three things:

  1. Player view distance
  2. Box size
  3. Number of islands
1 Like

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

… and a bit more tweaking

tweak

Tweak 2. I moved the reposition code into the island BP. And started them with a random timing offset between 0 and 1 seconds to spread the load.

This is 5000 islands, no frame hit…

tweak2

1 Like

Oh my god, you are insane. I’m currently a bit newbie in ue4, i will all day long implementing your code, and i have question about this:
Islands spawns by “random point bounding box” - that means islands will spawn in random locations each time if you came back or reload game? If so, is there a way to make “spawn” depend on the seed?

You mean you want it to be the same every time? Is anyone going to notice? :slight_smile:

Can you explain a bit more?

As you know, this isn’t really infinite islands, it’s a box of islands that craftily follows you around.

1 Like

The best example is probably the game Minecraft. When creating a world, the terrain is generated from a seed(random numbers), a player can share this seed and another player can insert this seed in startup and see the same terrain world. (Btw created world stored in file and more you explore more disk space it takes)
I want to be able to achieve that with islands locations(and their shape). I feel like with your method i can make spawn islands from not only randomness itself but also depending on the location of the box and random seed… But idk if it is possible or not.

Edit: also good example 2d noises(simplex, perlin etc.) they are randomness with the seed.
In voxel plugin i already have islands shapes with seed.

Yes, totally possible.

All random numbers in UE can be seeded. Instead of using ‘random point in box’, you would need to calculate the edges of the box yourself with

Another way, would be to generate the level once, and then record all the locations in the save game.

1 Like

Yes, totally possible.

All random numbers in UE can be seeded. Instead of using ‘random point in box’, you would need to calculate the edges of the box yourself with

image

Another way, would be to generate the level once, and then record all the locations in the save game.

PS: That function I gave, only fixes islands going off the edge of the box in XY, it’s very similar for Z also…

1 Like