I don't know if this is even possible but...

So I’m new to Unity, and been poking around learning about it. Yesterday I made some neat things with physics, today I’m learning about terrain and world building. I have an idea that isn’t yet fully formed, but I was hoping to get some feedback from people more experienced at this on whether or not it’s worth pursuing.

This idea goes back to MUDs, in fact (text-based RPGs). I built one years ago that used a 200x200 grid as a ‘worldmap’, or ‘wilderness’. Retro-RPG style, if you stepped onto a wilderness tile that had a zone present, you shifted scale and entered that zone, leaving the wilderness behind.

Now, the nifty part was, the wilderness rewrote itself as you traveled. What I mean is, instead of actually have a 200x200 grid of rooms, I had a 200x200 array of terrain types, which were associated with various description lines, features, objects, events, etc. When a player stepped into a wilderness ‘room’, it generated the description, contents, and goings-on within that room at that moment. If all players then left that room, and it was empty for two uninterrupted minutes, it ‘unrolled’ and would reroll next time someone entered.

This enabled all kinds of awesome things like - I had weighted chances for certain things to occur, like 0.001% chance of stumbling upon a traveling gypsy camp that sold special potions while exploring a certain forest, or a 10% chance of passing by an animal den that had an exit into a (also procedurally generated) little mini-zone with 5-8 rooms where you could slay wild animals and find loot. It allowed players to always have infinite, fresh content.

So my question is, is something like this possible with something like Unity? I mean, I’m sure it IS, but I’m having trouble envisioning the logic of it. Would it need to load new scenes every time you entered a new wilderness ‘tile’? Is there a way to make it more seamless - maybe have entry/exit points at the cardinal directions for each possible tile, and make it ‘roll’ adjacent ones when you stepped into a new one? What kind of impact would this have in a multiplayer game? I’m just not familiar enough with graphical game design and Unity in general to know where to start working on something like this. Anyone able to offer some insight or direction?

Here’s the flowchart for Unity, as far as I remember it:
http://con.structive.net/unity/possible.png

I can see many ways to implement it, most of them involving separate scenes. But let’s mention one way without different scenes:
-In the background, you have a scene which adapts to whatever the wilderness tile should have.
-The map is implemented as a GUI canvas, with an opaque panel covering the scene completely.
-Transition away the GUI after generating the scene.

That’s the quick way, but could be inflexible. A multi-scene way:
-Wilderness scene as per usual, with whichever GUI stuff it needs.
-Specific scenes per wilderness tile type, with their own GUI canvas and elements (possibly shared from a prefab).
-A surviving “environment” game object holding a script with all the basic parameters.

You can expand on that and use additive scene loading, which allows you to load the next scene after stepping on a border, and scroll to the new view. If you design the wilderness scenes to have its origin offset by the position in the grid of the world map, you should be able to additively load every scene if need be, allowing players to be in different scenes.

Thanks for your feedback! I’m kind of excited about this idea now. I’m still trying to wrap my head around it with a rather elementary understanding of Unity. What I’m thinking so far is something like:

-Create a scene for every wilderness tile.
-Create prefabs for a bunch of different possible ‘layouts’ for each terrain type.
-Have that ‘environment’ object you mentioned with a script in it that checks the terrain type of the tile the player is entering, and then grabs one of the possible terrains from the list of prefab terrains (terrain objects, in this case - little unclear there).

So if I did that, there’s a few things I’m a little stuck on. First, I would need to ensure that the ‘tile’ the player is entering has an exit/entrance in the direction the player is coming from. The easiest solution I can think up for this (short of making all terrain prefabs have the same entrance/exit points) is to rotate the terrain so that a designated point is the one that joins with the point the player is entering from. Does that sound like the best way to go with that?

Another thing - if the game were multiplayer, ‘generating’ the ‘tiles’ this way would get more complex. If one player is in an existing tile, and another enters an adjacent tile, the newly generated tile would need to have or not have an entrance/exit to the already-existing tile depending on if that one does or not. Any insight on how to address something like that?

Good - procedural generation is all the rage now, and it can actually be fairly easy in Unity :slight_smile:

I’d go with one scene per type. Jungle, desert, mountain, plains etc. Cities and villages could occupy just as much space on the world map, but be much more complicated scenes with their own unique generators which have further sub-scenes for places which can be entered.

The video linked below should have some ideas for this, but basically this can work:
-Each scene has many slots for different types of randomised objects:
–Entrance/exit slots have a few different possible positions, and once the correct number is generated the rest become scenery (sewers can possibly have ladders up right in the middle, outdoor areas only have openings at the edges)
–NPC slots according to terrain, friendly/neutral/hostile randomised as needed
–Clutter slots for trees, walls, rocks, scattered lootables, trash

So you start with a flat area and slots to place prefabs on from a grab bag which varies per terrain type. To extend this you could design templates for different variations of an environment. ScriptableObject is the good, old workhorse for this, so look at UT’s official tutorial.

I think you can find some interesting ideas from the Dungeon of the Endless devs:

https://www.youtube.com/watch?v=zPQOHX9hiL0