It makes me very happy, that this video still gets a lot of views after nearly 3 years :-D I would love to answer your questions here, cause you are all very kind. But I must admit that I turned my back on Unity in 2018 to continue with Godot and gdscript. Since then I have forgotten nearly everything on programming in c# or even starting a project in Unity. So I hope you understand if I can't support more detailed questions on this video any longer :(
Yes, @@electroman9254 , I think this is a good idea to add this to the code. I remember experimentating a little bit in this direction with code. But this was a looong time ago and I can't remember, because I am old now :))
If you are using an older version of the rule tile addon, make sure to use the RuleTile class instead of TerrainTile. I had problems figuring out why this won't work, hope this info will help somebody in the future. Great job Daniel, the grid and tile manipulation part helped me a lot!
This was a fantastic tutorial. First time I followed along I had no idea what you were talking about but after reading about cellular automata and watching your video again it made total sense. Thank you!
Great tutorial, worked flawlessly. Thanks so much for this, really helped me understand how to implement an procgen system using an established algorithm. Please keep doing this, it is definitely appreciated!
Really helpful video that has given me a lot of motivation - going to build off of your basic generation and see if I can get some logic going for my own tilemaps to create an environment for the player to explore. Thank you so much!
Truly amazing. Thank you for such a helpful guide and for providing your materials and project files to help tie up loose ends that may have not made sense in the video. You, Brackeys, and a few others have really helped me to create my own game. Cheers.
Hey I know this is an old video, but how do I change where the procedural generation starts. Say I wanted it to start at 100, 100 instead of 0,0. How would I go about doing that? EDIT: I found out how. For any of you wondering, I accomplished this by adding a new Vector3Int called startPosition, and adding it at the beginning of this: topMap.SetTile(new Vector3Int(startPosition.x + -x + width / 2,startPosition.y + -y + height / 2, 0), topTile); botMap.SetTile(new Vector3Int(startPosition.x + -x + width / 2,startPosition.y + -y + height / 2, 0), botTile);
How would this be implemented into a world you're trying to create in which there are multiple terrain resources that you also want to include on the map I.E. factorio where there are multiple types of resource nodes also procedurally generated on the map?
wow, thanks! I saved a lot of time with your tutorial and it's the perfect introduction to unity for me :D Your last video was about godot - did you stop working with unity? Also a litte question to your code: I can't interpret the line "terrainMap[x, y] = Random.Range(1, 101) < iniChance ? 1 : 0;" TerrainMap[x,y] will be filled with a random value, range 1-101. But the < iniChance ? 1:0 is not readable/interpretable for me :-S Could you give me a hint?
The question mark and colon is a ternary operator, which is basically a short if/else statement. If Random.Range(1, 101) < iniChance, return 1, else return 0.
IndexOutOfRangeException: Index was outside the bounds of the array. mapGeneration.genTilePos (System.Int32[,] oldMap) (at Assets/Scripts/mapGeneration.cs:90) mapGeneration.doSim (System.Int32 numR) (at Assets/Scripts/mapGeneration.cs:51) mapGeneration.Update () (at Assets/Scripts/mapGeneration.cs:128)
Thank you very much for this tutorial. Everything is working perfectly. I just have one question: You said if you want to remove borders then comment out something, could you please tell me which line of code should I comment out?
excellent programming, but the directions need to be a bit more synced with what you are doing. I only have 1 screen so if I am going to follow along with you I need to stop looking at what you are typing and when i come back you are typing something very different. makes it hard to follow at times.
Thank you. I really appreciate your constructive feedback. Actually this was my very first scripting tutorial and I know I quite have to improve on this. I will review the video and try to figure out how to get better at this.
Hey man! I absolutely love your tutorial, I have one question however. How would I go about laying out an array of tiles? Lets say I want to set 25% of 1 tile and 75% of another on the bottom layer? If anyone could help me with this I'd be very greatful.
@@adamex2270 Adamex in the dosim() theres an if statement that shouldnt be followed by curly brackets {} and should just have the next two line of codes that set the topMap n BotMap .settiles . If you have the {} then get rid of them
I followed along exactly and even used your script after mine didn't work and it doesn't work. I put in 'Debug.Log("Click")' inside of 'if (Input.GetMouseButton(0))' to push a line to console after using the mouse button. The line shows up, the map does not. Any help?
It's because of depreciated scriptable objet instanciation. You cannot use new Object anymore but must cast it as type :0 LavaTile myAT = ScriptableObject.CreateInstance("LavaTile") as LavaTile
So this is working as intended for me though I had to make a few changes to get it to work with my version of Unity. The question I have here is how this is working as it is. The portion of doSim that creates the top and bottom tilemap is what confuses me. I get that it's creating the top tile whenever there's a 1 as it iterates through the array. What I don't get is how it's using that same logic for the bottom tile since it's filling both of them. When I go look at the bottom tilemap it looks like it just fills the whole tilemap with the bottom tile. I mean it works and looks as I expect it to but I don't understand how it's logically doing that.
Okay, just saw what it is. I copied his tab indenting for the if statement. The second SetTile method runs no matter what the result of the if statement is so that's how it's filling it and is not part of the if statement at all.
Hi Daniel great tutorial. I was just wondering if you could explain the 'Birth Limit' and 'Death Limit' variables, as I'm not totally sure what they are doing.
So I know this is an old question but best as I understand it, the foreach before that variable is checked counts the number of neighbors within the 8 tiles around the current tile it's iterating through. It then compares the deathLimit and the birthLimit to the number of neighbors to determine whether the tile dies or if a new tile is born. If neighbors is less than the death limit, the tile "dies" (is set to 0). If neighbors is greater than the birth limit, a tile is "born" (is set to 1). If neither condition is met, nothing happens and the for x and y loops continue.
Hi @GGMemes, Very simple in Unity under Menu Assets -> Create -> Sprites -> Square. Then set the pixels per unit and a color of your choice. I do not know if this was possible already when I did this tutorial. So I created this rather complicated in a graphics program, by creating a new document 24x24 and exporting it as a png-file.
Hey there, any chance you can give a thorough explanation of how the "BoundsInt" works in general and in the context of this program? Cannot find good information about it on the internet. :/
Hi, I am sorry, but I turned my back on Unity and switched to Godot. So I won't do any more Unity tutorials. But in my Godot-Tutorial on the same topic I reproduce the BoundsInt Array with c#-Code, because Godot has no Bounds-Int: ua-cam.com/video/OKBVk1I4Ddk/v-deo.html I also made a visual explanation for this using some animated cells: ua-cam.com/video/0lWIAu8OO-A/v-deo.html So hopefully, if you watch this videos, it will give you a better understanding of how the Bounds-Int works. It's really good for Tilemaps, but also simple to reproduce with your own code.
hi it's very great tutorial really helped me i just have on question can i randomize the top tile like adding more than one tile and randomize it , i tried playing with the code a little bit but i cant find a method to do so can you help me with that and thanks in advance :)
Yes I am. Always used Vim at work, therefore I am much quicker with it . The extension for VS can be downloaded here: marketplace.visualstudio.com/items?itemName=JaredParMSFT.VsVim
Ich kann dir leider nich genau sagen, wiesos mir so schwer fällt, deinen Erklärungen zu folgen aber Sebastian Lauges Tutorial über Maperstellung mit Zellulären Automaten war für mich viel einfacher zu verstehen... (ua-cam.com/video/v7yyZZjF1z4/v-deo.html) ich glaub ich war von deinen Methoden- und Variablennamen teilweise verwirrt und habe auch überhaupt nicht verstanden, was der boolsche Parameter "complete" in der Methode "clearMap" zu suchen hat. Und im Allgemeine finde ich dieses Tutorial auch schlecht strukturiert: Du machtest mir nicht eindeutig genug klar, wann du welchen Teil des Algorithmus geschrieben hast und was welcher Teil deines Codes überhaupt macht. Ebenfalls fand ich es eine vertane Möglichkeit, dass du keine Zwischenstände präsentiert hast. So viel zu meinem Feedback über dieses fast drei Jahre altes Video, nimms mir bitte nicht persönlich ok :)
Ich schätze es sehr, dass Du Dir die Zeit genommen hast so eine ausführliche Kritik für mich zu hinterlassen. Und ich denke Du wirst mit dem meisten recht haben. Ich glaube ich habe damals sogar versucht Sebastian Lagues Stil zu kopieren. Ich war ein schlechter Dieb ;-). Leider kann ich nicht zurückgehen und meinem Vergangenheits-Ich sagen: "What have you DONE?". Andererseits: auch wenn ich heute vor Scham im Boden versinken würde, falls ich mir das Video erneut anschauen sollte, bin ich immer noch sehr froh, dass es nach so langer Zeit gut views generiert und mir ging es vor allem darum, zu zeigen, was mit dem damals neuen Tile-Editor von Unity möglich war.
@@DHofmann Jepp, das ist ja auch die Hauptsache :) Ohne dich hätt ich gar nicht erfahren, dass man Tilemaps auch per Skript generieren kann, hab also meinen besten Dank [^^]
It makes me very happy, that this video still gets a lot of views after nearly 3 years :-D
I would love to answer your questions here, cause you are all very kind.
But I must admit that I turned my back on Unity in 2018 to continue with Godot and gdscript.
Since then I have forgotten nearly everything on programming in c# or even starting a project in Unity.
So I hope you understand if I can't support more detailed questions on this video any longer :(
Thank you for the great tutorial!
Daniel Hofmann would you be able to add tress and stuff onto this code or would that all be separate?
Yes, @@electroman9254 , I think this is a good idea to add this to the code.
I remember experimentating a little bit in this direction with code. But this was a looong time ago and I can't remember, because I am old now :))
Daniel Hofmann ah ok thx
Maybe make a tutorial on how to do it on godot?
If you are using an older version of the rule tile addon, make sure to use the RuleTile class instead of TerrainTile. I had problems figuring out why this won't work, hope this info will help somebody in the future. Great job Daniel, the grid and tile manipulation part helped me a lot!
This was a fantastic tutorial. First time I followed along I had no idea what you were talking about but after reading about cellular automata and watching your video again it made total sense. Thank you!
Great tutorial, worked flawlessly. Thanks so much for this, really helped me understand how to implement an procgen system using an established algorithm. Please keep doing this, it is definitely appreciated!
it didnt work for me at all
:(
AMAZING!!! I have been hunting for this type of tutorial, you have done a great job and I was able to adapt to my code easily. Thank you so much!
Thanks a lot. I am glad it helped you. Your words are a great motivation to me.
Really helpful video that has given me a lot of motivation - going to build off of your basic generation and see if I can get some logic going for my own tilemaps to create an environment for the player to explore. Thank you so much!
Truly amazing. Thank you for such a helpful guide and for providing your materials and project files to help tie up loose ends that may have not made sense in the video. You, Brackeys, and a few others have really helped me to create my own game. Cheers.
Hey man, I think your tutorial is quite enlightening. Thanks.
AWESOME, thanks. This code is also pretty performance, I updated my procedural generator with this for a platformer. Thanks!
Thanks a lot. I am glad that the code helped you with your project!
this is pure gold to me, tank you
That was super helpful, thanks for putting that together. Keep up the good work.
Hey I know this is an old video, but how do I change where the procedural generation starts. Say I wanted it to start at 100, 100 instead of 0,0. How would I go about doing that?
EDIT: I found out how. For any of you wondering, I accomplished this by adding a new Vector3Int called startPosition, and adding it at the beginning of this: topMap.SetTile(new Vector3Int(startPosition.x + -x + width / 2,startPosition.y + -y + height / 2, 0), topTile);
botMap.SetTile(new Vector3Int(startPosition.x + -x + width / 2,startPosition.y + -y + height / 2, 0), botTile);
hello i using unity 2020 i have a problem i dont see under assets>Create Tile how create i them?
Wait those arent crabs dying
Amazing thank you for sharing this!
very goood film, thank you
How would this be implemented into a world you're trying to create in which there are multiple terrain resources that you also want to include on the map I.E. factorio where there are multiple types of resource nodes also procedurally generated on the map?
wow, thanks! I saved a lot of time with your tutorial and it's the perfect introduction to unity for me :D
Your last video was about godot - did you stop working with unity?
Also a litte question to your code:
I can't interpret the line "terrainMap[x, y] = Random.Range(1, 101) < iniChance ? 1 : 0;"
TerrainMap[x,y] will be filled with a random value, range 1-101. But the < iniChance ? 1:0 is not readable/interpretable for me :-S Could you give me a hint?
The question mark and colon is a ternary operator, which is basically a short if/else statement. If Random.Range(1, 101) < iniChance, return 1, else return 0.
@@Mauwh Thanks a lot! I didn't know this short if/else statement, you helped me a lot, Thank you!
What I don't get is how can the code tell which tile to use so everything correctly lines up graphics wise
IndexOutOfRangeException: Index was outside the bounds of the array.
mapGeneration.genTilePos (System.Int32[,] oldMap) (at Assets/Scripts/mapGeneration.cs:90)
mapGeneration.doSim (System.Int32 numR) (at Assets/Scripts/mapGeneration.cs:51)
mapGeneration.Update () (at Assets/Scripts/mapGeneration.cs:128)
I was just wondering, how does one make a procedural chunked tile map, with rule tiles, without the seams?
Have you figured it out? Cuz I’m in the same boat. Was going to do sub scenes, come to find out they don’t work with tile maps, and idk what to do lol
Thank you very much for this tutorial. Everything is working perfectly. I just have one question: You said if you want to remove borders then comment out something, could you please tell me which line of code should I comment out?
Thanks a lot. It is the line at 16:15 which should be commented out, if you want no border. neighb++
Could you perhaps create a new tutorial to explain how to make a scriptable tile in unity?
13:52
this is a completely random time stamp
it says i can't add the script because it needs to derive from mono behavior
excellent programming, but the directions need to be a bit more synced with what you are doing. I only have 1 screen so if I am going to follow along with you I need to stop looking at what you are typing and when i come back you are typing something very different. makes it hard to follow at times.
Thank you. I really appreciate your constructive feedback.
Actually this was my very first scripting tutorial and I know I quite
have to improve on this.
I will review the video and try to figure out how to get better at this.
How can i do a auto border as you did in the beggining of the video? trying to make this on my rpg to faster level design
Very good tutorial
Hey man!
I absolutely love your tutorial, I have one question however.
How would I go about laying out an array of tiles? Lets say I want to set 25% of 1 tile and 75% of another on the bottom layer?
If anyone could help me with this I'd be very greatful.
When i do this, the bottom tiles dont show
Turns out the bottom tilemap is in the same postion as top tilemap.
@@vortexplays4946 I have the same problem.
@@adamex2270 Adamex in the dosim() theres an if statement that shouldnt be followed by curly brackets {} and should just have the next two line of codes that set the topMap n BotMap .settiles . If you have the {} then get rid of them
@@vortexplays4946 Thanks, it worked.
thank you!
I followed along exactly and even used your script after mine didn't work and it doesn't work. I put in 'Debug.Log("Click")' inside of 'if (Input.GetMouseButton(0))' to push a line to console after using the mouse button. The line shows up, the map does not. Any help?
It was a unity bug. I had to start a new project and import all of the assets again, then it worked.
This could also be used to make more natural textures for pixel art.
everything was going well until i tried to assign the toptile tile asset in the inspector and it just wont let me
It's because of depreciated scriptable objet instanciation. You cannot use new Object anymore but must cast it as type :0 LavaTile myAT = ScriptableObject.CreateInstance("LavaTile") as LavaTile
So this is working as intended for me though I had to make a few changes to get it to work with my version of Unity. The question I have here is how this is working as it is. The portion of doSim that creates the top and bottom tilemap is what confuses me. I get that it's creating the top tile whenever there's a 1 as it iterates through the array. What I don't get is how it's using that same logic for the bottom tile since it's filling both of them. When I go look at the bottom tilemap it looks like it just fills the whole tilemap with the bottom tile. I mean it works and looks as I expect it to but I don't understand how it's logically doing that.
Okay, just saw what it is. I copied his tab indenting for the if statement. The second SetTile method runs no matter what the result of the if statement is so that's how it's filling it and is not part of the if statement at all.
@@darkmojojojo I was having the same problem, thanks for finding that.
Hi Daniel great tutorial. I was just wondering if you could explain the 'Birth Limit' and 'Death Limit' variables, as I'm not totally sure what they are doing.
So I know this is an old question but best as I understand it, the foreach before that variable is checked counts the number of neighbors within the 8 tiles around the current tile it's iterating through. It then compares the deathLimit and the birthLimit to the number of neighbors to determine whether the tile dies or if a new tile is born. If neighbors is less than the death limit, the tile "dies" (is set to 0). If neighbors is greater than the birth limit, a tile is "born" (is set to 1). If neither condition is met, nothing happens and the for x and y loops continue.
23:50
how did you create a texture box ???
please help me!!!
I can not do this
Hi @GGMemes,
Very simple in Unity under Menu Assets -> Create -> Sprites -> Square. Then set the pixels per unit and a color of your choice.
I do not know if this was possible already when I did this tutorial.
So I created this rather complicated in a graphics program, by creating a new document 24x24 and exporting it as a png-file.
Hey there, any chance you can give a thorough explanation of how the "BoundsInt" works in general and in the context of this program? Cannot find good information about it on the internet. :/
Hi, I am sorry, but I turned my back on Unity and switched to Godot. So I won't do any more Unity tutorials.
But in my Godot-Tutorial on the same topic I reproduce the BoundsInt Array with c#-Code, because Godot has no Bounds-Int:
ua-cam.com/video/OKBVk1I4Ddk/v-deo.html
I also made a visual explanation for this using some animated cells:
ua-cam.com/video/0lWIAu8OO-A/v-deo.html
So hopefully, if you watch this videos, it will give you a better understanding of how the Bounds-Int works. It's really good for Tilemaps, but also simple to reproduce with your own code.
@@DHofmann Thank you! That gave the push we needed to understand how it works!
Keep up the good work!
I've done all of the coding, but when i add my script to my empty game object i dont get any of the sliders showing, how do i fix that?
Make them public I think
hi it's very great tutorial really helped me i just have on question can i randomize the top tile like adding more than one tile and randomize it , i tried playing with the code a little bit but i cant find a method to do so can you help me with that
and thanks in advance :)
@@prettybigoof3135 hi im new to unity and C#, where should put the code
thank you so much!
里面代码有一段是错误的,导致重叠,生成瓦片时要改一改才行,
Awesome!
Oh thank you man
Thanks
thankyou :)
Is he in some kind of VIM mode ?
Yes I am. Always used Vim at work, therefore I am much quicker with it . The extension for VS can be downloaded here: marketplace.visualstudio.com/items?itemName=JaredParMSFT.VsVim
@@DHofmann
23:50
how did you create a texture box ???
please help me!!!
I can not do this
Great tutorial but i gotta say your spaces and wrong indentation drives me crazy LOL
Where is git?
Hey, good tutorial but for some reason the auto gen is very messy.. can someone help me pls
nvm XDD
A+
Might just be my shitty headphones but I can barely hear this
thx
Ich kann dir leider nich genau sagen, wiesos mir so schwer fällt, deinen Erklärungen zu folgen aber Sebastian Lauges Tutorial über Maperstellung mit Zellulären Automaten war für mich viel einfacher zu verstehen... (ua-cam.com/video/v7yyZZjF1z4/v-deo.html)
ich glaub ich war von deinen Methoden- und Variablennamen teilweise verwirrt und habe auch überhaupt nicht verstanden, was der boolsche Parameter "complete" in der Methode "clearMap" zu suchen hat.
Und im Allgemeine finde ich dieses Tutorial auch schlecht strukturiert: Du machtest mir nicht eindeutig genug klar, wann du welchen Teil des Algorithmus geschrieben hast und was welcher Teil deines Codes überhaupt macht. Ebenfalls fand ich es eine vertane Möglichkeit, dass du keine Zwischenstände präsentiert hast.
So viel zu meinem Feedback über dieses fast drei Jahre altes Video, nimms mir bitte nicht persönlich ok :)
Ich schätze es sehr, dass Du Dir die Zeit genommen hast so eine ausführliche Kritik für mich zu hinterlassen.
Und ich denke Du wirst mit dem meisten recht haben.
Ich glaube ich habe damals sogar versucht Sebastian Lagues Stil zu kopieren. Ich war ein schlechter Dieb ;-).
Leider kann ich nicht zurückgehen und meinem Vergangenheits-Ich sagen: "What have you DONE?".
Andererseits: auch wenn ich heute vor Scham im Boden versinken würde, falls ich mir das Video erneut anschauen sollte, bin ich immer noch sehr froh, dass es nach so langer Zeit gut views generiert und mir ging es vor allem darum, zu zeigen, was mit dem damals neuen Tile-Editor von Unity möglich war.
@@DHofmann Jepp, das ist ja auch die Hauptsache :) Ohne dich hätt ich gar nicht erfahren, dass man Tilemaps auch per Skript generieren kann, hab also meinen besten Dank [^^]
what
lacks explanation
Woow! Even more unreadable code!.... Please use sane variable names and correct conventions...
PS: I’m not saying this in a mean way…
Thx for the feedback and advice. Sorry, but I even do not remember how to code one line in unity or c# after 4 years.
Terrible naming conventions. "myB"? Seriously?