Procedural Generation in Unity 2D for Beginner
Procedural Generation
In this video we will be making a beginner level procedural generating tarran in Unity. Will will be making 2 types of Terran .
1 = Smooth land Generation
Script is Here:hatebin.com/dwyksgwqtp
2 = Flat Platform like Generation
Script is Here:hatebin.com/yswygqkhpl
You can download the asset bundle that I am making which has all the scripts that I have tough in my channel .
Its totally Free and the link is here:
chronoabi.itch.io/procedural-...
And While your are doing that why now follow me on
You can also follow me on
Instagram : / chronoabi
KZread: bit.ly/2CReUlQ
Twitter : / chronoabi
Discord : / discord
You can Support this channel on patron to get the latest video as quickly as Possible
Paytron: / chronoabi
Пікірлер: 106
This is by far the greatest beginner video on this topic. Clear, direct, well-edited, no extra junk. You are a fantastic teacher
Thank you so much! I always thought procedural map generation would be really confusing, but you made it seem so easy! Thanks for doing this!
Hey, this is amazing, it has really given me a new perspective on Procedural Generation.
@Jonny-op3wr
2 жыл бұрын
Same! I made procedural generation harder in my head than it actually was. Thanks so much ChronoABI!!!
3 years later - this is still one of the best ways to start procedural generation. Thank you! 🙏
Procedural generation was confusing until I watched this video. Tutorials by indians are better than school.
this procedural generation has bought me into a whole new level in unity thanks for the tutorial you're the best
Really appreciate this tutorial, you made it very easy to follow and understand whats going on.
This tutorial is pure gold, thanks!
soooo thankssss brooo !!! I looked for scripts everywhere +1 sub
Nice Tutorial! Helped me a lot.
This is so useful I subscribed
helped alot, helped me get to a point where I can add on to it
this is really good!
I'm a complete dumbass when it comes to coding and this absolutely helped! Thanks bro
Awesome video 👍👏👍
I would appreciate it if you could make a tutorial for procedural generation for a top down dungeon crawler style game. It would help me so much and I couldn’t thank you enough if you did. Thanks.
@itoaster__
Жыл бұрын
Not same youtuber, but made same video kzread.info/dash/bejne/X4WDpbpvg7mso84.html
Great !
Noice❤️. Thanks
thanks it is really very nice.
Great tutorial
Very simple explanation, I hoped to see some better algorithms than simple random numbers. Please follow the naming conventions and put the comments in the right place. This video is great for beginners, but beginners have to learn the syntax!! You should pay extra attention to putting the spaces after commas, capital letters on the right places and use the correct word choice for the functions and properties. Don't want beginners to get the habit of writing their code unconventially.
this is teaching me a lot better than brackeys tutorial
@shadybois4766
3 жыл бұрын
stop the cap brackey's tutorial's are better
@AttemptedPretzelMaker
2 ай бұрын
@@shadybois4766 stop the cap this is better (lower quality but better at teaching)
Thank you so much
400th like :) nice video!!
да, это очень оптимальный вариант, класс 👏
do you have an updated version for Unity 2022, with the new tilemap objects?
Thanks!
@chronoabi
3 жыл бұрын
Welcome!
Hey follow me on Discord. Link is here discord.gg/78q3HFnb69 You can ask for help , post what your working on and get motivated , show your funny bugs and memes and more.
@IlyasZeHunter
3 жыл бұрын
Bro this toturial is realy very nice I like your way of explaining
Thank you! This worked very well, except at the end I wanted to make the blocks a smaller size, and then when I would press play, the generation wouldn't be together, but split apart. How do I make them generate closer together?
@chronoabi
3 жыл бұрын
Blocks should not be smaller then 1.otherwise that happens
@qusaiagha5852
3 жыл бұрын
just make everything else bigger
@mrsarcasmbn9855
2 жыл бұрын
Just use floats instead of ints, that worked for me. Using a bigger scale messes up physics.
How can I make like a flat world like Mario but add holes to it
daami :D
@chronoabi
Жыл бұрын
Thanks bro
Hi Chrono! if you ever heard of game like Growtopia or Pixel Worlds it has a world generation how do i achieve that? thanks!!
Can you do this with bolt?
hello, great tutorial friend. Could you make a video explaining how to add some extra ores to this type of procedurally generated map? I would be very grateful :) Thank you +1 subscribed
@SolaFideSolusChristus266
2 жыл бұрын
I am a beginner/intermediate dev myself, but maybe do a for loop for every stone block with a random range of, maybe, 5 to 10. Make an int called orechance and make it equal to the random range in the for loop. Then, do an if statement where if orechance is greater than 7, make it an ore, otherwise make it stone. However I am very new to procedural gen and for loops in general so I have absolutely zero idea on how to put this in code
I want to generate the world very very deep and increasing height to over 10k make it lag a lot. How do I generate stuff only inside camera?
Unfortunly it is not working for me, in the script it says that there is an error(i copied you script from your link btw)
@chuckdushane
3 жыл бұрын
Same here for the obj = Instantiate(obj, new Vector2(width, height), Quaternion.identity); obj.transform.parent = this.transform;
what music did you use?
whats does adding [SerializeField] do? If its just to have it in the editor, making it public will do that no?
@toastyshrimp1882
3 жыл бұрын
public allows the variable to be used in other scripts, whereas [SerializeField] only makes it show up in the inspector and nothing else.
TIP: if tiles are toooo big or too small just change their pixels per unit to right size (for example 32p or 64p (it depends on size of your pixel art)
Жаль, автор перестал снимать видео. Было бы очень славно увидеть продолжение... Он действительно очень помог
@chronoabi
Жыл бұрын
Бро, есть небольшая серия про процедурную генерацию с перлиновым шумом, и я найду время, чтобы продолжить и эту серию. Я очень извиняюсь за грамматическую ошибку, это перевод.
@Miketo_Sanso
Жыл бұрын
@@chronoabi Wow, thanks for the answer! And you will forgive me for my mistakes, since this is also a translator(. In general, procedural generation is very cool) and it would be nice to learn more about it. But there is another problem related to this topic. How can I set different destructibility levels for different blocks? After all, this is a tile map. It turns out that you need to make several layers, and depending on which of the layers the mouse is aimed at, change the density value? Even our programming course doesn't know how to solve it, and they say I'm in a hurry :). Thanks again for the answer! It's very nice that you answered even in Russian. It's rare now... If you need help, I can send at least a small amount that I can give myself for the development of the channel. You really help people!
question there is an equal amount of space between each block can you help?
@chronoabi
4 жыл бұрын
That means your sprite is no big enough. To make it big enough go to your project and click on the picture that has that sprite and there will be a pixal per inch or something like that and it probably is set to 100 decrease the value and apply . Keep on decreasing and applying until that empty space is filled. I hope this helped
@solicity1785
4 жыл бұрын
@@chronoabi ah i figured thank you for the response but may i ask why how do i spawn it in a diffrent area cause every time my game starts it starts far from my player and out of view and so i was hoping to spawn it near my player aswell as implement caves got any fixes to the spawning placement?
@chronoabi
4 жыл бұрын
It starts from 0,0 so try changing the for loop's X and y value from X=0 to some other number
@solicity1785
4 жыл бұрын
@@chronoabi WOAH thank you i will try that later but thank you still
Hey, looks like that is a good procedural generation script. Can you show me how do i'll make cave generation with that procedural generation script? because i have struggle making the cave system by myshelf:( so can you or anyone tell me how do i'll make cave generation with that procedural generation script?
is there a way to add stuff like trees?
@chronoabi
3 жыл бұрын
You can have a system which spawns tree just above the grass tile and in some interval.
Hello ! What is the purpuse of [SerializeField] ? I don't understand :) Thanks
@chronoabi
Жыл бұрын
It's to keep your variable private but still show it in the inspector. If you don't want to write it like that, then you can use public.
What color is this? People: brown Now tell them what color you think it is Chroma: dirt
is there a way to add another tiles like iron, coal etc..
@chronoabi
Жыл бұрын
Probably just add those games object prefabs of iron and coal into the script and having a condition so that after a certain height or depth you instantiate those iron and coal game object. Sorry for the late reply and it has been a while since I looked at the code in this video but hope this helps.
is there a way to add a box collider i need it for my game
@malout7772
3 жыл бұрын
You can juste add it to your grass, dirt, and stone prefab. « Box collider 2D »
the hatebin didnt work:(
how to make infinite terrain
with big worlds, i need chunks. GIVE ME A CHUNKS TUTORIAL PLES
@chronoabi
3 жыл бұрын
Chill bro chill 😂🤣
@isimsizanimator1291
Жыл бұрын
@@chronoabi there is no chill if subject about game dev
can someone help, all my blocks are spawning in the same spot so only the grass is showing up, here is my code. using System.Collections; using System.Collections.Generic; using UnityEngine; public class ProceduralGeneration : MonoBehaviour { [SerializeField] int width, height; [SerializeField] GameObject Dirt,Grass,stone; void Start() { Generation(); } void Generation() { for(int x = 0; x { int minHeight = height - 1; int maxHeight = height + 2; int minStoneSpawnDistance = height - 5; int maxStoneSpawnDistance = height - 6; int totalStoneSpawnDistance = Random.Range(minStoneSpawnDistance, maxStoneSpawnDistance); height = Random.Range(minHeight, maxHeight); for(int y =0; y { if(y { spawnObj(stone, x, y); } else { spawnObj(Dirt, x, y); } } spawnObj(Grass, x, height); } } void spawnObj(GameObject obj, int width, int hieght) { obj = Instantiate(obj, new Vector2(width, height), Quaternion.identity); obj.transform.parent = this.transform; } }
How to fix fall throught terrain
@chronoabi
Жыл бұрын
Have you added a collider on those object?
@AttemptedPretzelMaker
2 ай бұрын
@@chronoabi Heyyy, hoping you respond soon. I think what he means is as the terrain gets further out (In my experiance) The height drastically lowers or increases. Like I have my hight set to 15, but about ~1000 blocks out it gets to like 50 or just stops generating.
It is a very bad approach to instantiate a game object to generate terrain. I would recommend using tiles
@raffaelechinotti5244
2 жыл бұрын
how would you do it?
@SaadTheGlad
2 жыл бұрын
@@raffaelechinotti5244 tilemap.SetTile(cellPos, tileBase)
@raffaelechinotti5244
2 жыл бұрын
@@SaadTheGlad many thanks! i'll try it out
Is it good at performance?
@chronoabi
3 жыл бұрын
I dont think so but you could use a system in which you only load the blocks that are on your screen.
>clicks on a tutorial >indian guy >learns more than 3 hours of stuff in 13 minutes
Bro, are you from Nepal?
@chronoabi
3 жыл бұрын
Haina hau sab le thapauna thale taa vanya😂😂. Kaa bata thapayo??
@Agent-zg5ec
3 жыл бұрын
@@chronoabi Location Kathmandu dheke k video ma.... Bro ko discord xa vne add garam nw...kaile kai kei siknu ya sodhnu milx ni tmlai
@chronoabi
3 жыл бұрын
@@Agent-zg5ec Discord taa xaina bro tara parkha ma banauxu ani join hunnu
@Agent-zg5ec
3 жыл бұрын
@@chronoabi ok
@chronoabi
3 жыл бұрын
Bro you are the first offical member of this channels discord community. Join hana ra kai aayena vane sodha hai ma sakdo madat garxu. Edit : Link chai dinai birsexu😂😂 discord.gg/dN2kU6
It crashes when I start gennerate
@chronoabi
Жыл бұрын
really sorry for the late reply but did you fix it ?
@Diamant-vf6qn
Жыл бұрын
@@chronoabi no
@chronoabi
Жыл бұрын
Give me the code or the project if you want in the discord server, it's night time here so tomorrow morning I will try to fix it
@Diamant-vf6qn
Жыл бұрын
@@chronoabi public int height = 30; public int widht = 30; public GameObject grass; public GameObject dirt; void Start() { } // Update is called once per frame void Update() { for (int x=0;x
Cam somebody plss help with my code? script: using System.Collections; using System.Collections.Generic; using UnityEngine; public class ProceduralGeneration : MonoBehaviour { [SerielizeField] int width; [SerielizeField] GameObject Dirt; // Start is called before the first frame update void Start() { Generation(); } void Generation() { for (int x = 0; x { Insantiate(Dirt, new Vector2(x,0),Quaternion.identity) } } }
@beepboop2851
Жыл бұрын
Instantiate(Dirt, new Vector2(x,0),Quaternion.identity); // the semi colon at the end is needed or else it won’t work
Норм гайд
isn't procedural generation when the world is being built as the player explores the world, in other words an infinite word.
@chronoabi
4 жыл бұрын
Yes and I am slowly trying to make and tech how to make tarreria
@williamknight2433
4 жыл бұрын
@@chronoabi YESS thank you that would be amazing!!
@solicity1785
4 жыл бұрын
@@chronoabi Sounds cool look forward to seeing it