Hello welcome to Episode four creating actual landscape so we’re just at the same place we were except I’ve gone ahead and shaved off the second level which was just a random fuzz we’re gonna be using some brushes to lay down some happy little trees well actually not Some trees but some terrain and I’m gonna show you how to do that this is part of the game where your design sense starts to come into play everyone builds a clone for their own reasons maybe you want one where it’s actually building spaceships maybe you want one where you Can shoot guns maybe you want one that said entirely in ruins all of this will really change how you build your terrain but I’ll show you how I do it and and hopefully you’ll be able to adapt it to your own needs so first things first I’m Gonna go ahead and turn on shadows in fact I already did all you have to do is take it from being go to the light and then take it from being no shadows to being hard shadows and I said it’s a very high resolution because it’s my Primary Sun so exactly what does that get me it gets me shadows see so you into these built-in shadows work fine for this now the shadows they’re not very good but they’re good enough for our purposes all right so after that what we need to do is need to build some Brushes now what is a brush my brush is simply a place that you paint a little bit of terrain well actually they’re so simple we’re not even gonna make them a class we’re just gonna make a must stand alone struct so they have a position They have a size we’re going to just use round brushes at this point and lastly they have a block type easy enough right so let’s go ahead and create a new I will do it here public that I name it brush let’s go ahead and aim it land Brush because there is in fact another class named brush and we don’t want to step on NATO’s so how do we create a brush well that’s easy enough let’s go ahead and make this I’ll go ahead and do it like this come on and we’ll go ahead and make this Random value times width plus transformed opposition of x0 a random value times width plus transformed opposition of Z brush dot size equals random value times width divided by two and brush dot type I’ll just make it like walked at 4’o and then we’ll return the brush so what does this get us well Instead of doing that that fuzzy part we’ll go ahead and do it here we have a brush we don’t have that one yet apply brush is a function we haven’t built let’s build it now so hold on a second pausing to spare you the pain of my agony allergies rather now normally I’d Just embed all this in a giant-ass for loop but I’ll make it real clear by doing it outside of the for loop portion out size now actually I’m going to go ahead and make it a little flat just to know I’m not gonna do that that would make our calculations annoying in The long run we’ll be creating a lot of different brush shapes and we don’t so you know we’ll be creating a lot of different brush shapes but for now that will work for float x equals mimics X is less than or equal to M X X X plus Equals 1 plus plus load Y a flyout well wasn’t that exciting so all we do now is we’re going to make sure that it’s within a circular radius otherwise a lot of square brush so if we’re outside of the circle then don’t paint otherwise do paint It’s that easy oh yeah it’s that easy so shall we see if that worked it works fine ah but it doesn’t work perfectly fine now does it at the edges of the chunks there is this horrible cutoff Oh such pain it’s nasty and horrible how do we fix that Oh No well I’ll show you the secret is to use a seed value so over here in terrain I’ve actually already set this up with a public variable named seed and then if seed is equal to zero when the game starts I send it to a random value and that is important because what we’re Going to do is when we generate brushes and so on and so forth well we’re gonna go ahead and say that random value equals C oh I need to get it that’s right camera we know where it is it’s on the camera okay we are value what did I Write that there we are so what is that going to do for us well first thing I thing to do is going to make all of our bricks look the same and in this case the brick they’re gonna make all of our bricks look exactly the same which is a Little bit depressing the second thing is going to do is going to make us remember that we need in fact to be larger than that so that we don’t have a zero size brush that we are alright so all of the blocks are the same that’s no Good we need to have all the blocks be different so obviously we can’t just set the C we need to do something more complicated we need to act like shatner now what we need to do is actually a little bit of maintenance work public list land brush get brushes for float X Float Z so this will let us get brushes for any block anywhere and since it’s any block anywhere this isn’t actually it’s a virtual function or a static function so that we can call it no matter who we are we can call it completely blind we’ll always be able to Get the brushes that we need come on you so actually what we need to do is we need to move this up here and we need to make this have the same float X load Z like so so why don’t I just do ya I set The seed here and then I add a brush here and that’s the problem so what does this accomplish exactly well we still have the same problem our seed value is the same all the time so we need to have it varied by depending on where this Where the where the brick is there’s a lot of way to do that a lot of ways to do that we’re going to go ahead and use a really easy one and make it equal to seed plus X plus Z and then we’ll go ahead and we can in fact do actual Useful stuff here but we’re gonna leave it like this specifically so that you can see the symmetry that that creates all right so that actually does not solve our problem of the brushes ending at the edge did I screw it up here oh yeah that’s right up here at the top we No longer get this we need to do list land brush brushes equals and then fryer brush there we are that ought to do it sorry stupid maintenance work that’s right I knew this was gonna cause initially I completely forgot about it we actually need to have an outside Source of width because width is not a static variable fortunately we do there it is and similarly we no longer need transformed opposition about X so generally I actually create these as static in the first place and I probably should have this time because it would Have saved a little bit of time well whatever so we definitely did not solve the problem where the things end at the edge of the chunk but we did solve the problem of everything looking the same well let’s go ahead and solve the problem of the things at the edges of The chunks and I’m going to show you how to do it it’s really easy but first I could have positive sneeze all right so the trick is this for float x equals transform top position to position X well why don’t we go ahead and make it easier than that int DX equals negative 1 DX is less than or equal to 1 DX plus plus for int DZ equals negative 1 DZ is less than or equal to 1 DZ plus plus can you tell we’re gonna do you should have enough information to tell there we go and right now you’re probably thinking Oh come on is it really that easy it is in fact that easy since every block will always return the same values regardless of who asks for questions when then you’re always going to be able to get the brushes and apply them so here’s a nice example this brush crosses over Into four different chunks and all of them worked fine so how is that that’s how you do it that’s how you create brushes now we’re going to just leave it at this for now later on we’re actually going to start to create different kinds of brushes and actual terrain but you Needed to understand the basic idea of seed based brush creation and now you do so I hope you enjoyed that and I actually am going to go ahead and do one more thing while you are here I’m going to go ahead and clean this up a little Bit so I’m just going to create some directories and dump crap into them and this way you won’t be confused as to where the heck everything went later on there we go garden is just the name of the scene that’s it thank you very much and I’ll this one was short but Hopefully pretty sweet Video Information
This video, titled ‘Tutorial: Minecraft in Unity #4 (Cross-chunk terrain)’, was uploaded by Craig Perko on 2013-06-02 14:44:01. It has garnered 8281 views and 37 likes. The duration of the video is 00:14:19 or 859 seconds.
Recording audio with air conditioner running almost as much as my nose… well, the actual content should still be useful. I’ll teach you the trick to crossing chunk boundaries with terrain!