creating a maze

I have been thinking about different ways I can generate a maze during run time and I had an idea and was wondering if it was possible using unity…

my idea was to have the maze as a texture and attach it to the plane and read the texture as an array and everywhere there is a line I would instantiate a cube… can that be done? and is so, where would I save the file and would it be saved as a text file or texture?

any help would be great :slight_smile:

Um… Ever heard of Heightmaps? Try using those instead Unity3D has those built in. :wink:

I don’t see how heightmaps have anything to do with the question. Anyway, I think this might get you started with making a maze from an array. It uses a text file rather than a texture.

–Eric

@Eric
He said he wanted to generate the maze out of an image or text file, he could use heightmaps to generate it out of an image.

If you mean randomly, I’ve been doing a bit with that. It’s pretty hard, because you would need to set up a double/triple (2d/3d) while statement, and than check if it’s compatible. My code is more for a 2d platformer, but I code post it if you want. You might get a solveable maze out of it once every few times, since now it’s just random, no logic at all.

if you would like i can try to help. (check your PMs)

thanks for all the help guys! :slight_smile:

i’ll look into the heightMaps and see if that could work and the thread that was posted really helped (that was kinda the idea i was going for).

as for making mazes using 3d and 2d arrays - i actually have a program that i’ve written in c++ that generates a solvable maze using a 2d arrays of cells where each cell has a right and bottom wall and using disjoint sets the maze is created. i thought about translating it to c# but it turned out to be a little more complex than i thought so i opted for creating a maze using a text file…

i’ll let you know how it goes :slight_smile: i still need to work a few things with how the maze itself works before i start generating new levels but all of you gave me a lot more to think about, so thanks again!