Тёмный

How to Procedurally Generate a Perfect Maze (Unity Tutorial) 

Ketra Games
Подписаться 26 тыс.
Просмотров 24 тыс.
50% 1

Опубликовано:

 

30 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 105   
@Aad1tya__42
@Aad1tya__42 7 месяцев назад
I'm here after watching GamesofVab video😂
@zeshufuno9177
@zeshufuno9177 Год назад
Great tutorial!But I want to ask there is way to make a maze entrance and exit?
@purple_fox_arts
@purple_fox_arts 4 месяца назад
You can basically put both at opposite ends because every tile can be reached from everywhere
@yours_indie_game_dev
@yours_indie_game_dev Год назад
to those asking implement entrance/ exit to the maze you can garb all the outer walls as such //if x=0 first row get the leftwall //if x==row-1 last row get the rytwall //if z=0 first colunm get the backwall //if z=cols-1 first colunm get the frontkwall add them to a list an perhaps find an index and clear 2 walls for entrance n exit x,and z being the index of the cell row and colums being the width and the depth as per this tutorial
@Ma_cieK
@Ma_cieK Год назад
This is a fantastic channel, and your talent for explaining how and why things work is truly remarkable. I sincerely hope that you will continue to produce more videos like this one for our community. Your contributions are highly valued and appreciated.
@KetraGames
@KetraGames Год назад
Thanks so much for this comment. It really made our day 😊
@marcoseliasmep
@marcoseliasmep Год назад
Wow the best tutorial about this subject! Thanks a lot for this video! It’s better than many complete courses that I’ve seen.
@KetraGames
@KetraGames Год назад
Thanks so much for this comment 😊
@mostly4real
@mostly4real Год назад
What is this best way to create this maze on a Coordinate that is not 0,0,0? as example: I want to have two different mazes in the 3D Platforming Tutorial for the Player to run through.
@HandsOnKnowledge
@HandsOnKnowledge Год назад
Super excited to see another upload, can't wait to watch the whole thing 😊
@KetraGames
@KetraGames Год назад
Thanks for this comment 😊
@HandsOnKnowledge
@HandsOnKnowledge Год назад
@@KetraGames and thank you for making such quality content 👍
@rainbowslime__
@rainbowslime__ Год назад
where u maze quit?
@runjimrun
@runjimrun Год назад
This is interesting! I'm working on a top down shooter with a random generated city, so this can come in handy
@Rahulsingh-theraha
@Rahulsingh-theraha Год назад
U might need to use wave function collapse instead of dfs algorithm
@runjimrun
@runjimrun Год назад
@@Rahulsingh-theraha Awesome, will look into this!
@ButterDog11
@ButterDog11 9 месяцев назад
Never mind I got it. For anyone who wants to know: Create a variable inside your mazecell script to store the number of active walls of that cell. Now in the maze generator script fetch all the cells who have only 3 active walls, as dead end cells are the only cells with 3 active walls.
@KetraGames
@KetraGames 9 месяцев назад
Glad you got it sorted. Thanks for sharing 😊
@W0rldbuilder
@W0rldbuilder Год назад
Wonderfully done! ♥ Might I suggest an addition to this system, wherein we can set a number of larger prefab rooms that get dropped into the maze (for enemy spawns, treasure, etc.)? Or would that be much too complicated?
@KetraGames
@KetraGames Год назад
Hi, thanks for the suggestion 😊
@bogumiwyrwa216
@bogumiwyrwa216 2 месяца назад
Hello, Greate tutorial :-) I have one question. Why you used values 1 and 10 in Random.Range(1, 10)?
@mrB25N
@mrB25N Год назад
Wow I needed a way to create an array of buttons, just the way you created the array of Maze cells, this is incredible timing! Thank you so much for this
@KetraGames
@KetraGames Год назад
Glad it will be helpful, thanks for this comment 😊
@5ld734
@5ld734 Год назад
This is fantastic and your channel is a gem this is exactly what I and many others needed to start to learn procedural generation
@KetraGames
@KetraGames Год назад
Thanks very much for this great comment 😊
@AlaaMasalmeh
@AlaaMasalmeh Год назад
Great tutorial! please upgrade this to First Person or Third Person maze escape with minimap
@KetraGames
@KetraGames Год назад
Thanks for the suggestion 😊
@Gilgamesh_king_of_heroes
@Gilgamesh_king_of_heroes Год назад
​@@KetraGamesthx for the video I'm already thinking 3d maze shooter😮😮
@Stranded13
@Stranded13 2 месяца назад
I’m making a maze horror
@chrislagos44
@chrislagos44 2 месяца назад
Wow! Sweet stuff! Unity is awesome 🎉 would be nice to add code to the script to create a second floor. So, when the algorithm stops. It's time to move to second floor but there needs to be a connection to the floor below. Stairs or ladders! Then when you set y= 0 just make it y = 1. I will try it out
@chrislagos44
@chrislagos44 2 месяца назад
Just by changing the size of each cell you will have a more open sort of maze. Like Wolfstein 3d
@weckar
@weckar Год назад
This is nice. However, this method tends to create a single long main path with relatively short side branches. To prevent that, you can iterate over a shuffled queue of all cells with unvisited neighbors instead. In addition; at the end of the process, you can knock down a couple extra walls at random to create loops and overall a less straightforward to solve maze.
@gasperkrevs5079
@gasperkrevs5079 11 месяцев назад
And how would one modify this code to create such effect? If you know by any chance. Thank you in advance.
@weckar
@weckar 11 месяцев назад
@@gasperkrevs5079 I would have to rewatch. I'll get gack to you.
@gasperkrevs5079
@gasperkrevs5079 11 месяцев назад
@@weckar Thabk you very much. If you have any idea how to do it, please let me know otherwise no problem
@gasperkrevs5079
@gasperkrevs5079 11 месяцев назад
I did manage to get a random maze so that is not jsut a single line, but now I want to know if it is possible to create a maze so that when you click on Play, it doesnt say Maze Cell (Clone) but instead the whole maze becomes a game object that I can move around and stuff like that. If you know what I mean?
@ButterDog11
@ButterDog11 9 месяцев назад
@@gasperkrevs5079 Fetch all the MazeClones and assign them a common parent gameobject, now you can move them together
@greg-b1i
@greg-b1i 2 месяца назад
how to fix the overlapping walls because they start flickering
@SyedHammadZada
@SyedHammadZada Год назад
How we can spawn collectibles within the maze path at every scene load? How about enemy ? Can we do path finding within the maze path?
@minhkhoa6081
@minhkhoa6081 9 месяцев назад
Sorry i have a question.what algorithicm you used in this generate map.
@ricardocreemers
@ricardocreemers 10 месяцев назад
I got an error with the OrderBy methode (row 44). It thinks it's a methode of the IEnumerator. I used using System.Linq; But it doesn't recognize it.
@bonaIdeaPro
@bonaIdeaPro 8 месяцев назад
Check if you wrote the right code here(should be IEnumerable, and not IEnumerator) : private IEnumerable GetUnvisitedCells(MazeCell currentCell)
@kamiii_samaa
@kamiii_samaa 6 месяцев назад
@@bonaIdeaPro THANK YOU SO MUCH
@Stranded13
@Stranded13 2 месяца назад
How do I change where the whole maze generates as it’s only starting on 0, 0
@CongTuSoi
@CongTuSoi Год назад
Hi, great tutorial! One question I have is how would you make it so that the maze is spawns at a determined position rather than (0, 0, 0)?
@johnbai842
@johnbai842 3 месяца назад
facing a little issue here 😭My maze cell won't be generated for some reason
@tiqosc1809
@tiqosc1809 3 месяца назад
dont understand how the recursive function work to pervent stuck in dead ends
@CarsNCrew
@CarsNCrew Месяц назад
please help, how to scale 2x the maze cell?
@runjimrun
@runjimrun Год назад
Somehow, my sprites (uploaded from sprite pack, containing multiple walking animations) cannot be scaled via PPU. It is sliced via cell size, nut I'm unable to change any properties like PPU and filter mode. Any ideas?
@gazzer4461
@gazzer4461 Год назад
Thanks Ketra! I always wondered how mazes were created in software.
@KetraGames
@KetraGames Год назад
Glad it was useful 😊
@ItachiX9
@ItachiX9 Год назад
That's awesome. I wanted to learn about maze algo.
@KetraGames
@KetraGames Год назад
Glad it was helpful 😊
@presiyangeorgiev9636
@presiyangeorgiev9636 Месяц назад
Amazing video, just what I needed!
@KetraGames
@KetraGames Месяц назад
Great, thank you 😊
@_Garm_
@_Garm_ Год назад
thank you :D
@KetraGames
@KetraGames Год назад
👍😊
@dylanrobinson830
@dylanrobinson830 8 месяцев назад
How do you fix the z fighting all the walls are too big making the pixels clash
@elisangelacardozo1788
@elisangelacardozo1788 Год назад
Great tutorial! Thank you!!!
@KetraGames
@KetraGames Год назад
Thanks for this 😊
@Madkevop7
@Madkevop7 8 месяцев назад
When the walls overlap, how to fix the corner walls z fighting
@quetsche
@quetsche Год назад
Hi ! What algorithm does it use ?
@KetraGames
@KetraGames Год назад
Hi, it uses randomized depth-first search 😊
@quetsche
@quetsche Год назад
@@KetraGames thanks!
@ThiagoPrego
@ThiagoPrego 10 месяцев назад
Thank you so very much. May the Lord bless you always.
@hamzamehmood9483
@hamzamehmood9483 Год назад
Thanks
@KetraGames
@KetraGames Год назад
👍😊
@ItsCrucible
@ItsCrucible Год назад
This is amazing! But, can you make a tutorial for it to be infinite? Like, Backrooms stuff I guess? I am making a horror game and I need an infinite maze.
@ButterDog11
@ButterDog11 9 месяцев назад
Great tutorial, any help on finding dead ends in the maze?
@ChrizSee
@ChrizSee Год назад
Great tutorial! Thank you!
@KetraGames
@KetraGames Год назад
Thanks for this 😊
@SpeedyGamerTV
@SpeedyGamerTV 3 месяца назад
Is there a way to make it so the mazecells are 6 meters?
@KetraGames
@KetraGames 3 месяца назад
Hi, if you watch the next video in the series we show how to increase the size of the cells - ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-dOI-N2QVly8.html. Hope that helps 😊
@henrysteven137
@henrysteven137 Год назад
yo this is so cool
@KetraGames
@KetraGames Год назад
Thanks for this comment 😊
@raelroque5595
@raelroque5595 Год назад
when are you going to do something more advanced? like interaction with or between npcs, quest system, etc.
@KetraGames
@KetraGames Год назад
Hi, thanks for the suggestions. We'll add them to the list of future videos 😊
@Vastlee
@Vastlee Год назад
Is there a reason you're still using Visual Studio 2019? 2022 is really great.
@KetraGames
@KetraGames Год назад
Hi, we stuck with 2019 as that was what was installed with Unity last time I checked. Now Unity 2022 is in LTS we'll probably upgrade to that and Visual Studio at the same time. Thanks 😊
@11b11b1
@11b11b1 Год назад
It would be the same concept for the 2D maze generation right?
@KetraGames
@KetraGames Год назад
Hi, yes the same concept would work for 2D 😊
@jovonsanon1
@jovonsanon1 Год назад
If I wanted to make the physically cells bigger How would I do that? Simply making the prefab parent object larger on the scale is causing problems ?
@KetraGames
@KetraGames Год назад
Hi, you would need to make some adjustments based on the scale of the prefab. So, for example if your pefab is 2x2 you would need to multiply the x and z positions by 2 when creating the initial grid. Hope that helps 😊
@someoneiguess23
@someoneiguess23 10 месяцев назад
@@KetraGames how would you do that?
@bobbydharrell
@bobbydharrell 8 месяцев назад
This Tutorial was amazing, Thank you. 1 Question though. I wanted to scale up my MazeCell Prefab to be twice as big so it would not be so cramped. But then it broke the Maze Generator .. how do i adapt the Maze Generator to handle any Cell size? Thanks in advance!
@magic00squirrel
@magic00squirrel 6 месяцев назад
Did you figure out how to fix this?
@bobbydharrell
@bobbydharrell 6 месяцев назад
@magic00squirrel yes, I went to the unity forums and another developer helped me out.
@aniellorenci7984
@aniellorenci7984 5 месяцев назад
@@bobbydharrell could you link what helped u or tell me what u did pls
@amypellegrini1732
@amypellegrini1732 5 месяцев назад
Great tutorial! 5 stars
@philberex
@philberex 4 месяца назад
Thank You for this great video!!
@KetraGames
@KetraGames 4 месяца назад
👍😊
@-Toon-
@-Toon- Год назад
What is the best way to scale the size of the cells without messing up the generation?
@KetraGames
@KetraGames Год назад
Hi, one way you could do it is to add an empty game object that you scale up or down. Then when you Instantiate the maze cells you can specify this as a parent. Hope that helps 😊
@-Toon-
@-Toon- Год назад
@@KetraGames this works to scale the cell prefabs, but the maze size/spacing between cells remains the same which results in the cells overlapping
@KetraGames
@KetraGames Год назад
Hi, this is because when using Instantiate it sets World position rather than the local position. You can fix this by adding the following line _mazeGrid[x, z] = Instantiate(_mazeCellPrefab, new Vector3(x, 0, z), Quaternion.identity, _parent); _mazeGrid[x, z].transform.localPosition = new Vector3(x, 0, z); You'll also need to use local position further down in the algorithm private IEnumerable GetUnvisitedCells(MazeCell currentCell) { int x = (int)currentCell.transform.localPosition.x; int z = (int)currentCell.transform.localPosition.z; Hopefully this should get it working 😊
@PolyVR2
@PolyVR2 11 месяцев назад
it doesn't let me drag the maze cell into the slot, how do i fix this?
@KetraGames
@KetraGames 10 месяцев назад
Hi, have you made the maze cell a prefab by dragging it into the Project Panel?
@PolyVR2
@PolyVR2 7 месяцев назад
@@KetraGames it works now :D. but one question. how do i change the size of the maze? like can i make the walls in the prefab bigger? or do i have to do something different?
@hggyuu
@hggyuu 11 месяцев назад
I want to code like you
@KetraGames
@KetraGames 11 месяцев назад
👍😊
@Blossomanukposi
@Blossomanukposi 3 месяца назад
This is sooo cool!!!
@KetraGames
@KetraGames 3 месяца назад
👍😊
@aarondelgado3421
@aarondelgado3421 Год назад
Great tutorial! You should expand on this tutorial by making into a series where one can add NPCs, doors, pickups, etc.
@sleazybot
@sleazybot 10 месяцев назад
I'm trying to add to this maze an object player(first person) but it doesn´t appears or fit into the maze, anyone haz any suggestion for me
@dannchap9946
@dannchap9946 9 месяцев назад
Your player has to be smaller than the cell prefab size. Just shrink the player object until it fall into the maze. Hope this helps.
Далее
Procedurally Generated 3D Dungeons
9:42
Просмотров 288 тыс.
The Most Impressive Scratch Projects
11:00
Просмотров 4,9 млн
Best FREE Software for Game Development in (2024)
8:01
20 Advanced Coding Tips For Big Unity Projects
22:23
Просмотров 186 тыс.
Coding Adventure: Clouds
12:50
Просмотров 1,2 млн
What size should your assets be? | HD 2D GAME ART
12:10
3 Hours vs. 3 Years of Blender
17:44
Просмотров 5 млн
MAKE A MAZE IN UNITY
30:51
Просмотров 18 тыс.