Grid Generation : Beginners Guide EP 1 - Unity3D

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone welcome to my series on a beginner's guide to procedural generation in this series we will be exploring concepts as generating 2d and 3d worlds generating and altering meshes as the series progresses we will be covering more complex subjects relating to procedural generation let's start the series off by taking a look as to what procedural generation is procedural generation is generating world's terrains maps and other objects through code and computing power we assign a set of rules per se that the computer must follow and carry out for example I assign a rule to state that the computer must generate a world of the size ten by ten I then want the computer to place objects based on the size of the world I give the computer the location of where to place these objects and then tell it to put everything together and generate the world let's have a look and we can do this through code now that we have outlined our rules we can begin to explore how to convert those rules into code pair our first rule we want to the world that was of ten by ten which we are defining here we can see here that we are creating a variable called world size X and assigning it the value of ten below that we are creating world size Z which we are also assigning the value of ten within the start function we are creating a for loop we are creating a variable X and assigning it zero we're saying if X is less than the world size X we want X to increment every time this loop runs we then encapsulate another for loop within the first for loop and we are creating a variable Z assigning it zero then we are stating if Z is less than world size Z we want Z to increment every time this loop is ran now we go back to our rules which say I want the computer to place objects based on the size of the world this is initially what these two for loops are doing now our third roars I give the computer the location of where to place these objects we are creating a vector3 called pause short for position when creating new vector3 so we must provide x y and z axes for the x axis which is defined here we are merely saying we want it to be x times our grid offset so we want this variable x by this variable for the y axis since we want it to be flat we are assigning its error we are doing the same as we did for the x axis that we are doing for the z axis we are saying we want Z times by our grid offset now that we have defined where we want these objects to be placed we can actually go about creating this object we create a new game object called block and we use the instantiate function provided by unity saying we want block game object which is a game object that we assigned in our inspector as the block to spawn followed by its position and its rotation quaternion the identity basically means we want the rotation to be that of the game object that we are spawning now to clean up our inspector we want to have this game object full under our world controller we are saying that we want this blocks transform dot set parent which is another function provided by unity to be this transform basically this game objects transform now we can go into unity and see what this is doing we can see in our hierarchy that we have an empty game object called world controller of which I have assigned it the generate grid script I've also assigned the block game object as a prefab which I manually made and inserted into the prefabs folder now when we go about running this we will see that we now have a grid generated you may be wondering why is it so weirdly spaced apart well that is where the grid offset comes in if you want a flat plane you mainly adjust this variable and you'll be able to either move the blocks closer in or further out thank you very much for joining me on the first episode on my series on a beginner's guide to procedural generation I hope that this episode shared some insight as to what procedural generation is and showcased a very simple form of procedurally generating a grid for our next episode we will be looking as to how to displace our grid by using Perlin noise
Info
Channel: CodingWithRus
Views: 3,937
Rating: undefined out of 5
Keywords: Unity, Unity3D, Procedural Generation, Procedural Terrain, Unity Procedural Generation, Beginners Unity, Unity Beginners Guide, Unity Guide, unity3d tutorial, unity3d basics, unity3d game, unity3d brackeys, unity beginner tutorial, unity c#, unity coding, unity course, unity for beginners 2020, unity game development, unity game tutorial, unity game engine, unity tutorial, unity 2d
Id: K_643wa9GSw
Channel Id: undefined
Length: 5min 11sec (311 seconds)
Published: Sat Apr 18 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.