Is it possible to make a map randomly generate walkways and paths? I am working on a project which includes a maze. The level itself has to be a maze, and i would like the levels to be generated randomly so that you can’t just follow the same path everytime and complete the maze which would make the game a one-time-playthrough kind of deal.
Would I be required to make many different maze plains which could then be randomly chosen from or could I actually make the walls and pathways and spawn points random each time?
I see it this way: I could make many different maps, which could be randomly chosen from and which in turn would give me total control over the maps. Or I could make the pathways, walls and spawns random each time, so that the game would stay refreshing each time.
The only problem I have with the maps generating walls and such randomly is that I have no control if I was to implement NPC’s or interactive objects.
Sure, you can generate your map procedurally as well. Interactive objects, NPC’s and Decoration then have to placed by a algorithm as well.
As a starting point you could scan the asset store for dungeon genarators and alike. There should be already a few interesting projects there.
If you want to do it by yourself, google is your friend.
My question is, how much experience do you have with C#, Unity and math etc? Some approaches to this problem gets really complicated. The topics you are looking for is procedurally generated mazes and procedurally generated meshes.
I would highly recommend something easier if you are new to programming. Did you know that the Diablo series uses techniques like this? You can especially see it in the first and second installments, the third is a bit of a let down…
OK Unity uses Scenes as Levels, the simplest and easiest way to use them is to build them in the editor and then use them as levels in your game.
Unity’s baked lighting and baked pathfinding work best with pre-built items.
Another option would be to generate the mazes using a random maze generator, but you lose the benefits of baked lighting for looks and baked pathfinding for NPC’s. (see previous good advice and links).
If you choose the random option then you will probably have to spend a bit more time working on NPC’s and a way to texture your maze so that it looks good without baked lighting.
You could however opt for a hybrid solution, if you make maze segments, chunks of maze that can fit together to make a larger maze then you might be able to achieve the best of both worlds. You’re NPC could live within single segments or domains.
[Note] this advice is based on using Unity 4.x, Unity 5.x may have improved dynamic navigation and lighting.
@Arowx you can keep the benefits of built in path finding and still do random content. You need to bake the path find area onto the shape of the ground of your level, then use those unity object things (totally forget the name) that can break up the pathfinding area. I have a really old post on that in these forums somewhere, where I loaded in wall prefabs of a maze onto the same ground that had the pathfinding on it.
Of course, you could also just put movement nodes on your map pieces so no matter how they fit together, there’s a chain of nodes for enemies to follow.