For anyone trying to add randomized exits to the maze, you can modify the 'Generate' method as follows: public static WallState[,] Generate(int width, int height){ WallState[,] maze = new WallState[width, height]; //Initially all the walls EXIST WallState initial = WallState.RIGHT | WallState.LEFT | WallState.UP |WallState.DOWN; for (int i=0; i< width; ++i){ for (int j=0; j
Thanks for this. I really love it. Just note you have a bug in your code. If you increase the size of the wall, it doesn't properly handle the position anymore. All you have to do is change the following line: var position = new Vector3(-width / 2 + i, 0, -height / 2 + j); It should be: var position = new Vector3(-width / 2 + (i * size), 0, -height / 2 + (j * size));
For those struggling with the scaling issue, you can adjust the scale using this script. It's more of a band-aid and not a proper fix. It may not be a good fix depending on what your game will be. Just make a script called MazeScaler and put it on your MazeRenderer game object. adjust the Scale setting to change the size, I use scale settings X:4 Y:9 Z:4 using System.Collections; using System.Collections.Generic; using UnityEngine; public class MazeScaler : MonoBehaviour { public float xScale; public float yScale; public float zScale; public void Start() { transform.localScale = new Vector3(xScale, yScale, zScale); } }
way higher quality than expected for even channels with thousands of subs, you've earned a subscriber! edit: took me several hours due to interruptions and the fact that for some reason you can't have multiple objects in the prefab or it won't scale right. one eye is twitching but it's working.
I would add it to an action RPG. Enter say a cave and randomly generate a large maze inside inside of it. You have to enter a door to enter the maze and there will be a disclaimer outside that after X minutes inside, the door will lock. When it does the maze will fill with lava killing the player (or whatever death mechanic - maybe a Minotaur spawns and smites the player). The maze can be filled with various loot and the loot gets progressively better the deeper into the maze you go, but it also becomes more disorienting.
Hey dude! Awesome tutorial! This is by far the one that was most useful to me. There was a part of the video in which you talked about a seed for generating the mazes and you never got to it :( Are you planning on making a video about that? If not, how could I generate a random seed at runtime? I'm kinda new to this and just can't get it to work. Thanks again for the tutorial, I learned a lot!I suscribed to the channel, and hope you upload more videos in the future, keep up the good work! :)
Hey, sorry been a little busy. To make this deterministic, th-cam.com/video/ya1HyptE5uc/w-d-xo.html -> at this point, when creating the rng variable, replace the /*seed*/ comment with an integer value. Here's the system random class instantiation for reference - docs.microsoft.com/en-us/dotnet/api/system.random?view=netcore-3.1#Instantiate . This would generate the same maze every time.
Incredible tutorial! This was so helpful! I just have two questions. One, how can I start the algorithm from the center of the maze? Would that even work? Two, how do you add an entrance and an exit wall? Thanks again for the great tutorial!
WallState should be called CellState. Also a cell could be flagged as "Unvisitable", reflecting the notion that the cell is not a small room, but solid concrete (or whatever), allowing for another feature of the maze - i.e. places where you can't go.
Hey, Great Video!! But can you tell how to simulate each step of maze generation?? Like the one, you have in the clip explaining the Recursive Backtracking algorithm.
I follow this exactly but when I try to attach my MazeGenerator script to the object I get "The script don't inherit a native class that can manage a script". I don't get it
Hi , i'm new to mazes ... but i'm stuck at understanding the .Generate method used in the maze renderer 10:00 where did it come from ? what is it ? can someone explain to me ?
Can you tell me more about the size value in MazeRenderer. I can't really use it even though its a serializedfield. I assumed it would increase the size of the walls but it doesn;t for me.
Is there a logical explanation on why we should delete the opposite wall? I mean, I tested without deleting it and shows a lot of "box" cells, which means the maze is not maze. But why this works?
It's not really the opposite wall. A same wall exist in one cell, and in the neighbor. So, when you delete a wall for one, you need to deleted it for both. explanation : 21:10
you can scale the grid by changing the position calculations to this var position = new Vector2(-(width*size)/2+(i*size), -(height*size)/2+(j*size)); Sandeep needs to improve his code readability for future tutorials
Actually I figured out a band-aid to this. It may not be a good fix depending on what your game will be. Just make a script called MazeScaler and put it on your MazeRenderer game object. adjust the Scale setting to change the size, I use a scale of 4 or 5. using System.Collections; using System.Collections.Generic; using UnityEngine; public class MazeScaler : MonoBehaviour { public int scale; public void Update() { transform.localScale = new Vector3(scale, scale, scale); } }
Hey, do you think you could tell us how you can make randomized exits to the maze? I would really appreciate it, I'm desperate at this point (also if someone could do endlessly generated chunks out of these, that would be amazing)
@@someonetookvolt oh no, was looking for some help😭 I completed the tutorial but found another one which seems alot easier, hopefully it goes well, thank you!!!
Hello you can modify the 'Generate' method as follows: public static WallState[,] Generate(int width, int height){ WallState[,] maze = new WallState[width, height]; //Initially all the walls EXIST WallState initial = WallState.RIGHT | WallState.LEFT | WallState.UP |WallState.DOWN; for (int i=0; i< width; ++i){ for (int j=0; j
I have the problem that my maze is skew, but i want to roll with a ball through it, so the ball rolls back when i dont press a key. In the Video its the same, look at 38:32, when he walk with the player, the Z-axis change. Anyone knows help?
Good thing I don't need a tutorial i'm just watching so I can see all of you be bad at coding lolololololololololololololololol XD XOXOXOXOXOXOXO no jk i suck at procedural generation
I've uploaded all the source + assets to github. Here's the link -> github.com/gamedolphin/youtube_unity_maze
How can I make the hallways wider?
@@zmichael4114 You ever find out how to do it?
Would be very helpful
For anyone trying to add randomized exits to the maze, you can modify the 'Generate' method as follows: public static WallState[,] Generate(int width, int height){
WallState[,] maze = new WallState[width, height];
//Initially all the walls EXIST
WallState initial = WallState.RIGHT | WallState.LEFT | WallState.UP |WallState.DOWN;
for (int i=0; i< width; ++i){
for (int j=0; j
Thanks for this. I really love it. Just note you have a bug in your code. If you increase the size of the wall, it doesn't properly handle the position anymore. All you have to do is change the following line: var position = new Vector3(-width / 2 + i, 0, -height / 2 + j);
It should be: var position = new Vector3(-width / 2 + (i * size), 0, -height / 2 + (j * size));
For those struggling with the scaling issue, you can adjust the scale using this script. It's more of a band-aid and not a proper fix. It may not be a good fix depending on what your game will be. Just make a script called MazeScaler and put it on your MazeRenderer game object. adjust the Scale setting to change the size, I use scale settings X:4 Y:9 Z:4
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MazeScaler : MonoBehaviour
{
public float xScale;
public float yScale;
public float zScale;
public void Start()
{
transform.localScale = new Vector3(xScale, yScale, zScale);
}
}
thanks alot!
Thanks man, really appreciaste it :)
way higher quality than expected for even channels with thousands of subs, you've earned a subscriber!
edit: took me several hours due to interruptions and the fact that for some reason you can't have multiple objects in the prefab or it won't scale right. one eye is twitching but it's working.
I really like how subtle the video went , AWESOME👍
THANK YOU!! Your video saved my final project for a course!
i am also using it for my project but failed to generate maze, need help?
I would add it to an action RPG. Enter say a cave and randomly generate a large maze inside inside of it. You have to enter a door to enter the maze and there will be a disclaimer outside that after X minutes inside, the door will lock. When it does the maze will fill with lava killing the player (or whatever death mechanic - maybe a Minotaur spawns and smites the player). The maze can be filled with various loot and the loot gets progressively better the deeper into the maze you go, but it also becomes more disorienting.
THANKS NOW I CAN MAKE THE BACKROOMS :)
Amazing video!! So informative
Hey dude! Awesome tutorial! This is by far the one that was most useful to me. There was a part of the video in which you talked about a seed for generating the mazes and you never got to it :( Are you planning on making a video about that? If not, how could I generate a random seed at runtime? I'm kinda new to this and just can't get it to work. Thanks again for the tutorial, I learned a lot!I suscribed to the channel, and hope you upload more videos in the future, keep up the good work! :)
Hey, sorry been a little busy. To make this deterministic, th-cam.com/video/ya1HyptE5uc/w-d-xo.html -> at this point, when creating the rng variable, replace the /*seed*/ comment with an integer value. Here's the system random class instantiation for reference - docs.microsoft.com/en-us/dotnet/api/system.random?view=netcore-3.1#Instantiate . This would generate the same maze every time.
@@_sandeepnambiar hi! thanks for the reply, i had figured it ut already but the link you provided was very helpful too! :)
Your code is awesome!
Great video. Thanks for sharing !
Wow this tutorial is really good. Great job on explaining what ur doing new sub from me!
Incredible tutorial! This was so helpful! I just have two questions. One, how can I start the algorithm from the center of the maze? Would that even work? Two, how do you add an entrance and an exit wall? Thanks again for the great tutorial!
I didn't watch the tutorial until the end, but all you need to do is to select a node in the center as a starting node, I suppose
@@aleksandrb4635 Exactly - you can make your maze generate from any point, and it should work just fine.
how can I change the Floor and wall scale, that way its big and not small like 0.1
This is amazing! Do you think you could show us how to make an exit?
Hi, did you figure out how to do this?
@@hani8261 Nah unfortunately not. After tinkering around with it I turned to some other projects.
@@Beastie-nk7on awh, alright thanks :D
WallState should be called CellState. Also a cell could be flagged as "Unvisitable", reflecting the notion that the cell is not a small room, but solid concrete (or whatever), allowing for another feature of the maze - i.e. places where you can't go.
is there a way to change the spaces/path of the maze and is there a way to add rooms?
Could you explain how to setup the free look camera and the controlls of the third person controller
Can you apply this same algorithm to create a 2D maze in unity?
Hey, Great Video!! But can you tell how to simulate each step of maze generation?? Like the one, you have in the clip explaining the Recursive Backtracking algorithm.
that will be awesome
I follow this exactly but when I try to attach my MazeGenerator script to the object I get "The script don't inherit a native class that can manage a script". I don't get it
You have to inherit from Monobehaviour to attach to an object.
I am using ur algorithm in my fps game...
Hi there!
How can i add the player and enemys in a random way inside the maze ?
Is that complicated?
Best Regards
I also want to add
Is this maze procedurally generated? Does the layout change everytime you hit play ?
It does!
not sure
Hi , i'm new to mazes ... but i'm stuck at understanding the .Generate method used in the maze renderer 10:00 where did it come from ? what is it ? can someone explain to me ?
How do I make the maze bigger? I.e. make it have more turns and twists, etc. I don't care about scaling, I just want a lot larger maze.
still my maze is not generated, can you help me
Can you tell me more about the size value in MazeRenderer. I can't really use it even though its a serializedfield. I assumed it would increase the size of the walls but it doesn;t for me.
th-cam.com/video/ya1HyptE5uc/w-d-xo.html -> the width/height need to be multiplied with the size as well
@@_sandeepnambiar Thank you for including this, I also had the same issue.
how do i increse the cell size
This is cool but if you try to increase the size the whole generator breaks. Is there any fix to that?
What is text editor u are using bro
Same question. It's looks like vim but IDK...
Are 2 walls drawn between adjacent cells? If so, won't there be z-fighting issues?
Yep I think so. I should revisit this tutorial to get that fixed. Among other bugs.
@@_sandeepnambiar But since the material colours are the same in both - there will be fighting going on, but no-one will notice!
Is there a logical explanation on why we should delete the opposite wall? I mean, I tested without deleting it and shows a lot of "box" cells, which means the maze is not maze. But why this works?
It's not really the opposite wall. A same wall exist in one cell, and in the neighbor. So, when you delete a wall for one, you need to deleted it for both. explanation : 21:10
Tks a lot from Brazil
You're welcome!
you can scale the grid by changing the position calculations to this var position = new Vector2(-(width*size)/2+(i*size), -(height*size)/2+(j*size));
Sandeep needs to improve his code readability for future tutorials
How can we make levels? How it can be saved
I would like to make an infinite maze, is this possible using unity?
it is resolved
How to make this maze generator for PUN2?
Type 'WallState' does not contain a definition for 'HasFlag'
anyone found a good way to spawn a player or object in a open space within the maze
how to change the size of the maze?
i have the same question
Actually I figured out a band-aid to this. It may not be a good fix depending on what your game will be. Just make a script called MazeScaler and put it on your MazeRenderer game object. adjust the Scale setting to change the size, I use a scale of 4 or 5.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MazeScaler : MonoBehaviour
{
public int scale;
public void Update()
{
transform.localScale = new Vector3(scale, scale, scale);
}
}
very good video but I can't learn how to open the spacing between the walls
Hi did you figure out how to do this?
Hey, do you think you could tell us how you can make randomized exits to the maze? I would really appreciate it, I'm desperate at this point (also if someone could do endlessly generated chunks out of these, that would be amazing)
Hi, did you figure out how to do this? I would like to do the same but haven't figured out how ;??
@@hani8261 gave up after a week of trying, I hope you'll have more luck than me
@@someonetookvolt oh no, was looking for some help😭 I completed the tutorial but found another one which seems alot easier, hopefully it goes well, thank you!!!
@@hani8261 you're welcome! good luck
Hello you can modify the 'Generate' method as follows:
public static WallState[,] Generate(int width, int height){
WallState[,] maze = new WallState[width, height];
//Initially all the walls EXIST
WallState initial = WallState.RIGHT | WallState.LEFT | WallState.UP |WallState.DOWN;
for (int i=0; i< width; ++i){
for (int j=0; j
I have the problem that my maze is skew, but i want to roll with a ball through it, so the ball rolls back when i dont press a key. In the Video its the same, look at 38:32, when he walk with the player, the Z-axis change. Anyone knows help?
sorry, i mean the Y-axis
helpful video, but how can I made the corners look better?
you have to make a script to target all the walls once they are generated, and in my case, set the x axis scale to 1.3. cleaned them right up
@@RealFakePhD i know im 10 months late but if you have the time could you explain to me how to target and change the walls once they're generated?
@@RealFakePhD NEVERMIND IM STUPID
@@ouijajuice9496 I don't remember at this point but I do also have a script somewhere in the comment section that had the code I used to scale
I have question, how to make inlet and outlet?
Make warpers
When I do this Unity freezes. Is this because of the while?
I'm pretty sure it is. You should be careful around whiles, maybe try to put a counter variable in your while
thanks.
Pov: I am here for my Backrooms
Can you send the code for the Maze Generator Script in the chat ?
9:55 for me later
Good thing I don't need a tutorial i'm just watching so I can see all of you be bad at coding lolololololololololololololololol XD XOXOXOXOXOXOXO no jk i suck at procedural generation