Creating a procedural ocean in Unity

This all started as a testing function. The ocean in The Last Shore used to be completely handcrafted, but I wanted to experience the game more like a first time player. It’s really hard to pretend you don’t know where the next island is, when you actually do.

So, I got this system up and running as a test for myself. Once it was going, it was pretty clear that it was very interesting, and it opens up possibilities for a New Game+ playthrough.

Step 1: Place Islands

Each island has a major placement circle around it, and a minor placement circle.


The larger circle governs placement of the islands; no island major circles are allowed to overlap.

The main direction of the game is intended to be (generally speaking) from lower left to upper right. That’s the direction of the wind, and it is always pushing you toward the end of the game.

So, the first move is always to place the home island at (0, 0), in the lower left corner. Then I build an array of vectors pointing to the up and right.


The second island is placed down, at (0, 0) as well. Then it gets pushed along a randomly chosen vector until it is no longer overlapping the home island. The vector used is removed from the list of available vectors.



Now, I go ahead and place each of the other islands. Vectors keep getting removed from the original vector list – this ensures a good spread of islands, and prevents randomly getting a giant string of islands in single file.

Also, the islands are placed in the order they should be visited in the game. Due to the randomly selected vectors, there may be later islands that are somewhat closer than earlier islands. For my game, this is just fine, as I place a big emphasis on exploration and discovery. It does raise the burden for design, though; you need to be able to show the player – through game mechanics only – that they aren’t ready for certain islands yet. In the end, I think this is a great design restriction – making exploration meaningful, much like in most metroidvania games where you see something that you obviously can’t get to yet, but it piques your interest about what new ability will unlock that area.



And finally, I place the boss island. It always gets a vector near the middle of the spread of vectors, guaranteeing a placement somewhere near the top right corner of the map.


Step 2: Place Details

Now that the islands are all in place, the details need to go in. This is where the smaller placement circles come into play.

Island details include collectibles, towers that extend your sight range, creatures, and ambient things like rocks, shipwrecks, and seaweed. Each detail has its own placement circle, which can’t overlap with any of the smaller island circles. It also can’t overlap with another detail’s circle.

For each island, I build a vector array that points generally toward the rest of the islands. For an island that ended up in the middle of the map, this is a circle; the rest of the islands get vectors that point across a range toward the other islands.

I place all of the details at a minimum distance from their parent and then… start pushing!



This step is probably where I’ll continue working on this system the most as development goes forward. Right now, as all of the details get placed, they sometimes push across the map from their original location as they search for room. So far, this hasn’t been an issue, as most of the details are generic enough to be placed anywhere. But as I start to create assets that are more island-specific, I’ll probably do a round of placing those and then place the more generic ones, to ensure that specific details stay close to their parent.

Step 3: In-game Treatment of Details

Each of the details is actually a level file that is loaded when the player gets near enough. For many of the colorful details (fish, tube worms, etc), I randomly generate a color scheme for each island, and tint assets appropriately as I load the files.


Moving Forward

The Last Shore is still very much in development, and I’m sure there will be more changes to this system as it nears completion.

Here are some samples of complete worlds generated by the system:



Follow me here or on twitter to keep up-to-date on development of The Last Shore!




Leave a Reply

Your email address will not be published. Required fields are marked *