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

  • @cb2818
    @cb28182 жыл бұрын

    This is by far the greatest beginner video on this topic. Clear, direct, well-edited, no extra junk. You are a fantastic teacher

  • @joachimsaindon3658
    @joachimsaindon36584 жыл бұрын

    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!

  • @MuddyWolf
    @MuddyWolf4 жыл бұрын

    Hey, this is amazing, it has really given me a new perspective on Procedural Generation.

  • @Jonny-op3wr

    @Jonny-op3wr

    2 жыл бұрын

    Same! I made procedural generation harder in my head than it actually was. Thanks so much ChronoABI!!!

  • @shahroznaeem
    @shahroznaeem2 ай бұрын

    3 years later - this is still one of the best ways to start procedural generation. Thank you! 🙏

  • @kodakzak2836
    @kodakzak2836 Жыл бұрын

    Procedural generation was confusing until I watched this video. Tutorials by indians are better than school.

  • @fluffystuff
    @fluffystuff Жыл бұрын

    this procedural generation has bought me into a whole new level in unity thanks for the tutorial you're the best

  • @DonTheDevMC
    @DonTheDevMC2 жыл бұрын

    Really appreciate this tutorial, you made it very easy to follow and understand whats going on.

  • @ArdaIskender
    @ArdaIskender Жыл бұрын

    This tutorial is pure gold, thanks!

  • @jooj_kk
    @jooj_kk4 жыл бұрын

    soooo thankssss brooo !!! I looked for scripts everywhere +1 sub

  • @kahzn
    @kahzn3 жыл бұрын

    Nice Tutorial! Helped me a lot.

  • @redstone_bucket2973
    @redstone_bucket29733 жыл бұрын

    This is so useful I subscribed

  • @PhantomCatGame
    @PhantomCatGame Жыл бұрын

    helped alot, helped me get to a point where I can add on to it

  • @prismyre6074
    @prismyre60743 жыл бұрын

    this is really good!

  • @MisfitOhMy
    @MisfitOhMy2 жыл бұрын

    I'm a complete dumbass when it comes to coding and this absolutely helped! Thanks bro

  • @muniruboss
    @muniruboss4 жыл бұрын

    Awesome video 👍👏👍

  • @redstone_bucket2973
    @redstone_bucket29733 жыл бұрын

    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__

    @itoaster__

    Жыл бұрын

    Not same youtuber, but made same video kzread.info/dash/bejne/X4WDpbpvg7mso84.html

  • @SquidyGuitar
    @SquidyGuitar4 жыл бұрын

    Great !

  • @anshulsingh8326
    @anshulsingh83263 жыл бұрын

    Noice❤️. Thanks

  • @zed8970
    @zed89704 жыл бұрын

    thanks it is really very nice.

  • @cambo7622
    @cambo76222 жыл бұрын

    Great tutorial

  • @teamredstudio7012
    @teamredstudio70126 ай бұрын

    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.

  • @deepseamapping6187
    @deepseamapping61874 жыл бұрын

    this is teaching me a lot better than brackeys tutorial

  • @shadybois4766

    @shadybois4766

    3 жыл бұрын

    stop the cap brackey's tutorial's are better

  • @AttemptedPretzelMaker

    @AttemptedPretzelMaker

    2 ай бұрын

    @@shadybois4766 stop the cap this is better (lower quality but better at teaching)

  • @tgd694
    @tgd6943 жыл бұрын

    Thank you so much

  • @mutterficker19
    @mutterficker193 жыл бұрын

    400th like :) nice video!!

  • @user-se7ih2xn8u
    @user-se7ih2xn8u7 ай бұрын

    да, это очень оптимальный вариант, класс 👏

  • @tranceemerson8325
    @tranceemerson8325Ай бұрын

    do you have an updated version for Unity 2022, with the new tilemap objects?

  • @mlnz2991
    @mlnz29913 жыл бұрын

    Thanks!

  • @chronoabi

    @chronoabi

    3 жыл бұрын

    Welcome!

  • @chronoabi
    @chronoabi3 жыл бұрын

    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

    @IlyasZeHunter

    3 жыл бұрын

    Bro this toturial is realy very nice I like your way of explaining

  • @pizzapockets848
    @pizzapockets8483 жыл бұрын

    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

    @chronoabi

    3 жыл бұрын

    Blocks should not be smaller then 1.otherwise that happens

  • @qusaiagha5852

    @qusaiagha5852

    3 жыл бұрын

    just make everything else bigger

  • @mrsarcasmbn9855

    @mrsarcasmbn9855

    2 жыл бұрын

    Just use floats instead of ints, that worked for me. Using a bigger scale messes up physics.

  • @chodeydev
    @chodeydev Жыл бұрын

    How can I make like a flat world like Mario but add holes to it

  • @mandhustudios
    @mandhustudios Жыл бұрын

    daami :D

  • @chronoabi

    @chronoabi

    Жыл бұрын

    Thanks bro

  • @growhax1590
    @growhax15903 жыл бұрын

    Hi Chrono! if you ever heard of game like Growtopia or Pixel Worlds it has a world generation how do i achieve that? thanks!!

  • @preflopstore9718
    @preflopstore97183 жыл бұрын

    Can you do this with bolt?

  • @marcos.driguez
    @marcos.driguez3 жыл бұрын

    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

    @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

  • @suprememarshal2015
    @suprememarshal20152 жыл бұрын

    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?

  • @ancolia8772
    @ancolia87723 жыл бұрын

    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

    @chuckdushane

    3 жыл бұрын

    Same here for the obj = Instantiate(obj, new Vector2(width, height), Quaternion.identity); obj.transform.parent = this.transform;

  • @Ignagamer27
    @Ignagamer273 жыл бұрын

    what music did you use?

  • @SuperNightmareID
    @SuperNightmareID3 жыл бұрын

    whats does adding [SerializeField] do? If its just to have it in the editor, making it public will do that no?

  • @toastyshrimp1882

    @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.

  • @wolfie3657
    @wolfie36573 жыл бұрын

    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)

  • @Miketo_Sanso
    @Miketo_Sanso Жыл бұрын

    Жаль, автор перестал снимать видео. Было бы очень славно увидеть продолжение... Он действительно очень помог

  • @chronoabi

    @chronoabi

    Жыл бұрын

    Бро, есть небольшая серия про процедурную генерацию с перлиновым шумом, и я найду время, чтобы продолжить и эту серию. Я очень извиняюсь за грамматическую ошибку, это перевод.

  • @Miketo_Sanso

    @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!

  • @solicity1785
    @solicity17854 жыл бұрын

    question there is an equal amount of space between each block can you help?

  • @chronoabi

    @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

    @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

    @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

    @solicity1785

    4 жыл бұрын

    @@chronoabi WOAH thank you i will try that later but thank you still

  • @klikchannelini766
    @klikchannelini7667 ай бұрын

    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?

  • @Sydders_
    @Sydders_3 жыл бұрын

    is there a way to add stuff like trees?

  • @chronoabi

    @chronoabi

    3 жыл бұрын

    You can have a system which spawns tree just above the grass tile and in some interval.

  • @Tchooki
    @Tchooki Жыл бұрын

    Hello ! What is the purpuse of [SerializeField] ? I don't understand :) Thanks

  • @chronoabi

    @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.

  • @3emad.065
    @3emad.065 Жыл бұрын

    What color is this? People: brown Now tell them what color you think it is Chroma: dirt

  • @slaeman
    @slaeman Жыл бұрын

    is there a way to add another tiles like iron, coal etc..

  • @chronoabi

    @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.

  • @shadybois4766
    @shadybois47663 жыл бұрын

    is there a way to add a box collider i need it for my game

  • @malout7772

    @malout7772

    3 жыл бұрын

    You can juste add it to your grass, dirt, and stone prefab. « Box collider 2D »

  • @Seth1re
    @Seth1re11 ай бұрын

    the hatebin didnt work:(

  • @wolfie3657
    @wolfie36573 жыл бұрын

    how to make infinite terrain

  • @McMistrzYT
    @McMistrzYT3 жыл бұрын

    with big worlds, i need chunks. GIVE ME A CHUNKS TUTORIAL PLES

  • @chronoabi

    @chronoabi

    3 жыл бұрын

    Chill bro chill 😂🤣

  • @isimsizanimator1291

    @isimsizanimator1291

    Жыл бұрын

    @@chronoabi there is no chill if subject about game dev

  • @jettlewis1609
    @jettlewis16094 ай бұрын

    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; } }

  • @25_centai
    @25_centai Жыл бұрын

    How to fix fall throught terrain

  • @chronoabi

    @chronoabi

    Жыл бұрын

    Have you added a collider on those object?

  • @AttemptedPretzelMaker

    @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.

  • @serbanchisca1158
    @serbanchisca11582 жыл бұрын

    It is a very bad approach to instantiate a game object to generate terrain. I would recommend using tiles

  • @raffaelechinotti5244

    @raffaelechinotti5244

    2 жыл бұрын

    how would you do it?

  • @SaadTheGlad

    @SaadTheGlad

    2 жыл бұрын

    @@raffaelechinotti5244 tilemap.SetTile(cellPos, tileBase)

  • @raffaelechinotti5244

    @raffaelechinotti5244

    2 жыл бұрын

    @@SaadTheGlad many thanks! i'll try it out

  • @KelvinCipta
    @KelvinCipta3 жыл бұрын

    Is it good at performance?

  • @chronoabi

    @chronoabi

    3 жыл бұрын

    I dont think so but you could use a system in which you only load the blocks that are on your screen.

  • @feeney8715
    @feeney87155 ай бұрын

    >clicks on a tutorial >indian guy >learns more than 3 hours of stuff in 13 minutes

  • @Agent-zg5ec
    @Agent-zg5ec3 жыл бұрын

    Bro, are you from Nepal?

  • @chronoabi

    @chronoabi

    3 жыл бұрын

    Haina hau sab le thapauna thale taa vanya😂😂. Kaa bata thapayo??

  • @Agent-zg5ec

    @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

    @chronoabi

    3 жыл бұрын

    @@Agent-zg5ec Discord taa xaina bro tara parkha ma banauxu ani join hunnu

  • @Agent-zg5ec

    @Agent-zg5ec

    3 жыл бұрын

    @@chronoabi ok

  • @chronoabi

    @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

  • @Diamant-vf6qn
    @Diamant-vf6qn Жыл бұрын

    It crashes when I start gennerate

  • @chronoabi

    @chronoabi

    Жыл бұрын

    really sorry for the late reply but did you fix it ?

  • @Diamant-vf6qn

    @Diamant-vf6qn

    Жыл бұрын

    @@chronoabi no

  • @chronoabi

    @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

    @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

  • @Mojzer_
    @Mojzer_ Жыл бұрын

    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

    @beepboop2851

    Жыл бұрын

    Instantiate(Dirt, new Vector2(x,0),Quaternion.identity); // the semi colon at the end is needed or else it won’t work

  • @yujeck
    @yujeck2 жыл бұрын

    Норм гайд

  • @williamknight2433
    @williamknight24334 жыл бұрын

    isn't procedural generation when the world is being built as the player explores the world, in other words an infinite word.

  • @chronoabi

    @chronoabi

    4 жыл бұрын

    Yes and I am slowly trying to make and tech how to make tarreria

  • @williamknight2433

    @williamknight2433

    4 жыл бұрын

    @@chronoabi YESS thank you that would be amazing!!

  • @solicity1785

    @solicity1785

    4 жыл бұрын

    ​@@chronoabi Sounds cool look forward to seeing it