Game Development and Game Design Unity 3D Build a Unity City Building | Generalist Programmer | Skillshare

Playback Speed

  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x

Game Development and Game Design Unity 3D Build a Unity City Building

teacher avatar Generalist Programmer, I am the generalist programmer

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

31 Lessons (3h 47m)
    • 1. Introduction - Our city builder game in Unity 3D

    • 2. Procedural Terrain Generation in Unity 3D Part 1

    • 3. Procedural Terrain Generation in Unity 3D Part 2

    • 4. Procedural Terrain Generation in Unity 3D Part 3

    • 5. Procedural Terrain Generation in Unity 3D Part 4

    • 6. Procedural Terrain Generation in Unity 3D Part 5

    • 7. Procedural Terrain Generation in Unity 3D Part 6

    • 8. Texture and Materials for our Terrain

    • 9. Blender 2.82a Modelling a low poly tree

    • 10. 2.82a Blender texture painting our model, create materials and exporting to unity

    • 11. Modelling a low poly tree in Blender

    • 12. Blender texture painting our model, create materials and exporting to unity

    • 13. Import our tree into Unity 3D

    • 14. Spawn our trees on our terrain

    • 15. Setup Unity 3D project for object placement

    • 16. Importing our models and materials

    • 17. Basic building placement,start placing buildings

    • 18. Fixing the building placement and snapping to grid

    • 19. Camera scroller,scroll our map with mouse

    • 20. Adding our rocks to our terrain

    • 21. Setting up post processing

    • 22. Adding post processing effects, fixing the camera, stylizing the scene

    • 23. Fixing up some visuals in our game

    • 24. Creating the mini map

    • 25. Creating our Game UI

    • 26. Particle System Effects

    • 27. Adding more buildings

    • 28. Connecting our UI so we can select buildings

    • 29. Fixing our building colors

    • 30. Setting up our economy and the singleton pattern

    • 31. Expanding the economy manager script

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.





About This Class

Want to learn game development and game design? Unity 3D is a game engine used to build games for PC, Mobile and Console platforms. Have you ever wondered how to build games from scratch. In this course I will show you how to build a low poly RTS (Real Time Strategy) style City Builder Game.

With a little bit of basic programming and some basic graphics. We will put together a City Builder with game UI, lighting, post processing, mini maps, a basic city economy which you can extend on.

We will create our UI using Inkscape a free vector art drawing tool and Blender a free 3D modelling tool. I will show you how to create basic assets, texture them, UV unwrap them and export them to Unity 3D in order to use them in your own version of this course project. 

It is good to be aware that I take a live stream unedited approach to teaching. With this you get the added benefit of seeing where you can go wrong and how you can overcome challenges and fix problems within your own unity project. 

Here is a more detailed list of the unity 3d skills and features you will learn in this course.

  • Unity 3d rigid bodies and gravity
  • Unity particle systems
  • Raycasting and other techniques
  • Pooling
  • c# designs patterns in unity
  • Unity materials and texturing
  • Post processing to make our game look awesome

You will also learn the followng:

  • Blender modelling
  • Blender uv unwrapping
  • Texture painting

At the end of the course you should have a functional real time strategy city builder which you can expand if you like into a full rts or city builder game. With your own assets, own game mechanics and own economy. The basics in this course makes sure the core mechanics of rts/city builders is built so that you can expand the project with your own ideas. If you are new to game development or game design then this course is the ultimate quick and dirty way to get into game development quickly especially if you are interested in using 3d as part of your game design.

References,citations and sources, here are some of the useful resources that supported the formulation of certain aspects of this course some in part and some in full: (A source for geometry generation)

Brackeys (Great resource for learning game development and unity, was particularly useful for the research for the mini map and terrain generation lecture)

Meet Your Teacher

Teacher Profile Image

Generalist Programmer

I am the generalist programmer


I have over 15 years experience in software development and plc programming and industrial automation. I am a hobbyist in game development using unity 3d and godot game engines and all things programming. I have worked in various sectors and positions in my career. Starting over 15 years ago in programming and development. I have experience in building commercial quality software solutions in the artificial intelligence, mobile, embedded hardware space for large corporations. With high demand for integrated software solutions. Some of my titles throughout my career include, software developer, senior software developer, lead architect and tech lead. I have experience in electrical and electronic development and integration with software where I would create full A-Z solutions. As well a... See full profile

Class Ratings

Expectations Met?
  • Exceeded!
  • Yes
  • Somewhat
  • Not really
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.


1. Introduction - Our city builder game in Unity 3D: Welcome to my unity three D course building and Archie Ace, a real time strategy or city people their game. Here is what we will be building in this course a basic like police city boulder that you are elements such as these buildings lighting a fix procedural terrain generation for generating random to rains, which we can build our cities on. Particle Fix such Aziz in the post processing and Archie iStar camera, which we will be writing some code for as well as, well, maps which most RTs in city building games have. So if you want to learn how to make this city builder game joined my course now. 2. Procedural Terrain Generation in Unity 3D Part 1: So let's start by creating in the unity project. So open up your unity hub and select the three D template project name for this. I was just beginning it. Surgical, of course, is the perfect name and Indus it create. Once that is, then you should be presented with a view like this where you can actually start creating you're seeing. But for the first, bigger in the Siri's, we going Teoh just be looking at creating some terrain so that we can just get started with something visual for our city builder game. So let's start off with just creating into game object, which we've been going to take on. Give it some burgesses and son geometry and in what we're going to be doing is applying some Perlin noise to it is to give it a bit of a random generated terrain sort of look and feel. So let's get started arrestable in your hero key, right? Click and click on Create Inti came object renamed the An Object to Terrain. So just for now, what we need to do is just a few things just to sit up, up to rein game object and then we will actually get into the cutting part in the next video. So let's just go. And I had some tags, and what we need to do is go over here to the right. Well, selecting your train object at tag, they hit this little plus sign here and in terrain and safe. And let's just go back to you to reign over here and make sure got terrain object selected . So later on in this course, we're going to use this tag to actually decent collision detection with me. Place our buildings on altering, uh, mixing want to do is add a component calls, uh, mish collider. This is going to allow us to do collision detection on our actual mess that we're going to be creating. Also, add a mish render. This is for women. Want to add some materials, and Russell two things to our mesh later on. Also leads Adam mesh filter, which is gonna allow us to be able to get our miche and recent filtering on it later on and be able to actually create some burgesses which we can be in generate all terrain with. So that's all you need to just get your terrain objects it up for now. In the next video, we're going to be dealing with the extra coding off, generating a terrain and planks and Perlin noise to it to give it some randomness. See you in the next one. 3. Procedural Terrain Generation in Unity 3D Part 2: now that we've created are touring object. We want to start jumping into the code of our terrain generation in order to get started. Go down to your project tab over here and right click to create any folder. So just to keep everything tidy Bank Credit Scripts folder. We're going to hold a lout scripts for our game, going to scripts on right Kick again and create a scene shop script. No, I'm its terrain generates and open it up by hitting Enter and it should open up in visual studio now, First of all, what we want to do is we want to create a few variables which we're gonna be using for all terrain generations. So the very first thing we're going to be creating is a wish on will pull it, miss. We will be generating Amish basically from some lotuses. And then we're going to being plagued us back into our mission shelter, which we created a component for on our NT object in the previous video bean victor, three array off points or disease And how lotus is essentially work is it's a point in really spice, which has got a X Y and z component it So for our terrain mostly going to be the X and the easy access that we're going to be affecting. And then we will use Poland boys to offset our Y access with pity Moyes Calculation. But you will see that later on in this in this video next to you would need some triangles because we need to fit in our geometry with some triangle points. We can actually build up rail geometry and not just have points in our no terrain. And we need to other variables which were inspector to see somebody making in public and the public and ex plots family defaulted to 30 on Azzan blocks also revolted to 30. So these blocks are basically a full block which has been generated in Amish which in our case, is going to be a one by one sized block in three D space. Now you start method. What we're going to do is just initialize some of these levels, so don't miss. We just going to initiate Teoh object and we want to know get our component of our miss filter so that we can assign our mission to you are created the next we want Teoh. Just create some new methods which were going to do so using update at this time in this script that we're just going to remove it on. We're going to create two benefits which will allow us to for one create our terrain geometry and in secondly, allow us to update our German tree whenever it's required. So this dead myth that could then be used later on if you want to create water effects when you want to continuously update terminations and do some type of animation. But for this course we are going to be doing the physical terrain, so we will just like build at the update mish method, first of all, So let's start off with a big English Teoh be doing to its finish, and we're going to be doing great strain geometry. Create a in geometry. We will just be building up our geometry for up to running with Brutus is and we're going to be filling it in right triangles 4. Procedural Terrain Generation in Unity 3D Part 3: The first thing we want to do is we want Teoh, tell us script how big our planes right is going to be saying political victors. And the size of this array is going to be exp looks plus one most large bar Z blocks one. The reason for the plus one is that the start counting from zero in a raise, not one. So we're just adding additional one just to move about points up one more space. So then what we're gonna do is we're going Teoh through our points and start building up some type of bro to seize. Unless that we can use to the in grand generate our geometry. So we started for the in Z ankles era to make it a bit more care smaller than two rz blocks breast salutes the old is the blocks of creating. Then we want Teoh do the same thing again on we want to do through our explodes. We're going to sit X equal to zero and X and less than or equal to exploits and x plus plus so that they just threw one of them. There would be one to do inside these loops is to now build up some type of geometry. So basic scenes, what we can do is just sit a flat geometry at this point before we actually do some Perlin noise. You just want to add variable I as well just to do some counting on our points. That's is there initially, Onda, we want increments it here. So plants by is account for our roads. Basically for our queen's on now we're going to sign it a victor three on. We want to do the X offset by one. We can make this bigger. This is basically the size of how larger actual terrain blocks will be. I'm just going to make a teeth with this course because when you have a little bit of a larger terrain which wouldn't apply some textures too, just make it look a little bit more cleaning on. We're going to sit this wide position to one point their flights well late to replace it with some Perlin noise, which will then give us the variation in our terrain. So next thing on the news, when a in Z comes to well, just make a little bit bigger and we will just increment it so that we can assign all our prince will allow these moves that the game to be doing from here. What we want to do. We want to start building up some triangles and triangle. Basically, there will be two triangles fitting into our our points because our points will essentially want to turn into a quiet and quad will require six points inside in order to for two triangles in in that block. So for that we're going Teoh initialize are triangles by sitting in your ray and we're going to use our X blocks multiplied by R Z blocks multiplied by six for us. Six different inverted. Sees Richard acquired for our two triangles. That's it. It is hard. When are grid's blocks seven shooting going to start of the sun Critics counter. So we just need to start of the in critics off Sierra and we want to you have a trying to come for us to keep track of our for angles and where we are, you know, great generation at this point from here, what's going to be doing is we're going to be building apart triangles and we're going to be incriminating. Are trying to come by six Each time we built up quiet with two triangles just so that we can use are trying to counter six burgesses forward. 5. Procedural Terrain Generation in Unity 3D Part 4: So once again, we're going to start with a basic loop off into Z equals zero went busy less than rz blocks , busy plus plus. And then, obviously, inside here, we're going to have to live around exes as well. Listen, Mr Explodes X plus plus. And then from here, we can start building up our triangles array. Were we going to your science? And Vertex is and extra coordinates, which we've taken from a previous array of points, which we then can feed into triangles. So we're going to start off with triangles and it's gonna be the zero of triangle plus triangle counts unless going to be Is there a critics adding anything way going to be doing the next one? Thanks. Triangle in our set up six plus the triangle count. It is just so that we can keep living from 0 to 6 points in our three d space for the triangle points. So we're going to get adding good takes plus the X number of blocks plus one and repeating this process quite a bit. So I was going to paste this. I just think the modifications that we need this just going to being committed by one which time? Four on the final one to make up six. Try six points in the triangle. This is 5th 1 So do we. Weren't really adding exploits. People just be adding the heretics. Both of these we'll be earning explodes again and then finally explode. Apps Plus So now we've built up some type of triangles, But now we need to tell where curd or ah, fruit that we need to know Move for further with our Vertex is really add of it. Plus plus separate checks on you need to add are trying to come meet at six because each time we're adding six values in triangles array outside of this just to allow for us to the new from the first round to the second grow in on the Z access we need to know increment our vertex again once a complete X salute has been done, sir, Once again, we just need to incriminate Albert takes terrible. Now this is pretty much done and it's ancient. Generates are triangles for us. Ah, now we need to actually do the update mish method, which is actually very simple. It's just going to take in our points that we created, and it's going to taken out triangles and then assigned to our actual mish collider and filter because we're going to be needing that later on or collision detection. 6. Procedural Terrain Generation in Unity 3D Part 5: so to complete our update may Schmitter to be going to vegetable Start with Michener Clear which is just going Teoh, make sure our missions clean and has no previous clean. So anything that are left over from a previous Randall build of our actual game. So the next thing we need to do is sign Our verte sees also informational courtesies includes points they need to assign are triangles triangles on Then what we also want to do just to get our collider Sit up reading Teoh, get our message Colliders called component this collider and this is going to allow us to do collision detection which we're going Teoh need for actually placing our buildings on office on our terrain. So she had Nash and in a silent you are actual mission that we generated. Then basically, we just need to do one more thing. Teoh recalculate animals. So our normals are basically geometry which allows us to populate some type of lighting in our scenes without their some parts of altering is probably going to you like a little darker or lighter in some instances and was just going to liquid. So definitely don't forget Teoh recalculate normals and then just done. One thing we also going to add in your is to draw some gizmos that if you look at Unity Project, you'll see that there is this Ratomir which contend Dismas on Earth and you can see it's good, for example, our directional light which is sharing in our scene view. But these gizmos m show up in our game beer. Listen able, but you seem to you we can actually see what our terrain generator is actually doing. And we can use this for debugging in the sorts of issues we might have. So then the next thing we need to just do them just to allow these gizmos mean to writing code. So there is a built in intimated called on drawing is less So you have to use this exactly that otherwise it won't work. And should we just get festival? Just check if we have any points. If Quinn's is no, then you don't want to be anything. We just want to return. Otherwise we're going. Teoh, the loop three are Quince Andrea actually going to draw them? As God is my sin are seeing Okay, Sorry. What we'll do is we'll use it supposed Teoh. Droll spears. Just basically because Spears are quite easy to draw. The only need a point and radius called actuals as here. So I'm going to make this 0.5. If so, if you can see it nicely and get an idea of where lower queens O r not from here. What we want to also do just to get this working me to go back into unity and to something also like to do just to make it easier for us to actually see our terrain or double clicking terrain so that we focus on where are during object will be. And then I click on the main camera and go to 10 object and the line was view so that we make sure that our cameras actually pointing at our terrain. So in the next video, what we'll be doing is we will just be testing this out running and immunity so that we can actually see how we draw gizmos. And we're going to apply some pool and noise as well so that you can start seeing that nice little bit of terrain generation. So see you in the next one 7. Procedural Terrain Generation in Unity 3D Part 6: So now, before we actually taste out our terrain generation, we need Teoh. Just make sure that we are actually calling our methods and our see shop script. So festival start May 3rd. We need to create terrain geometry and we need to call our update place. It's an I'll save this on and it's a very to unity and actually taste this out. So every open immunity and previous video, we actually set up our camera to actually look at our terrain so that we can see it on before we hit the play button. Just take a terrain generator script and pick up the terrain object and this dragon over to the inspector too allow the script to actually be assigned to terrain. So now it's great and hit the play button on DSI the result. So you can see with our spears, which is Drollas case. Mercifully disable. This is live is my spring girl. It is. You have that previously the script where we had a y value of zero or sorry one. We've got, like a flat surface on our terrain and now we actually want to start applying some Poland boys just to get some offset on our part to rain. So let's hit back into visual studio and make some changes to a script to allow for Poland noise. So I just want to allow us to have a little bit more flexibility with this so that you actually play around with our polar morals values. So it's just create some variables for example, beginning to be brings. We're going to replacing those ones there if with the Y value which is going to be generated by upward envoy. So it's something you're so that we can actually see what those values are as they're being updated. So I'm going to be ideal public like Why value? And I want to add some way off adjusting a Perlin noise on the fly and seeing the result in our scene. So I'm going to add a few more variables, which we can adjust by. Then. Speakers at Public float give it a default that 0.5 at a public field z offset to deserve when fired. If his longtime I'm going Teoh a public flirt. Why off since a 1.5 its people. So what I wanna do is I want to create this inspector as a arranged value or a slider, sir. In order to do that right when I get it of any between their 0.1 if and thing rusty little to just I'm just added the these values can modify them. And we're going to come down to our create terrain geometry. And now we got actually going to apply our Perlin noise, which is going Teoh be assigned to a Y value symbolism libels if dot president noise and we're going to be using our experience multiplied by X upset, which will be interesting, it more, inspector. And we're going to be using our Z value multiplied by offsets. And then we're going to be offsetting by our wilds. It also lt Justin Ahrens, Victor. So now we've got a Y value, which is president always generated so we can substituted here on they can actually start to see the effect of the pearl annoys all artery. So that's it. Back into unity and give this around Well, now it's not going to update on the fly. It just because we haven't actually implemented away refreshing are geometry and Amish, but we can hardly see some form of perfect, which is being applied to our terrain. Let's get back to God. You can see there's a bit of a variation in all terrain right now and to see who's built in these both states, but they're not really updating anything at this point in time. So let's go out of here on back into visual studio just to give ourselves a way of actually updating. So it's at a void. Six updates. And inside here we just going Teoh a create terrain, geometry, gin and also going to be running a bigness threats and how we should be able to see changes on the fly with our our Perlin noise, which is being applied to our terrain. Let's go back into unity and play around with this a bit. They play, and you can see if we like these libraries. You can see things are moving around Different sits, could see as well that are Y values also changing, and here we have really mountainous or really flat surfaces. So that is this tutorial now, and video on pulling noise and how you can actually use it in your terrain. For example, issue If you did want to do something more like a water affect. You could actually then going animate this sort of value. And Cassie, it could have almost like a little flow of, like, little ocean still up to you. What, you want to do that? But that is the end of this section on procedural terrain Generation in later parts of this course will actually be doing generation of items on a range of Southern. We can create randomly generated worlds. So that's the end of the section to see you in the next video. 8. Texture and Materials for our Terrain: So we now got ourselves a terrain which has generated. But if you put this extremely bad looking pink So in this video we're going Teoh, just be touching us up a little bit so that we actually have some decent textures that actually look like grass or to rail the festival before we start with the actual graphics. This will create some holders for us, which we can use to just over buys our assets. British Lad created graphics folder, which then have a textures fuller the materials folder that these two folders we're just going to say about textures and materials that we create for a textures. I'm going to be using federal shop where you could use gimp if you don't have further shop , which is a free tool for creating graphics. So what we really need to do is just be able to create a canvas, which is 1000 drinking four by 1000 and four pixels. So for this text, wrongness and keep it really simple. Use a radio radiance so that we don't have any seeing this texture problems when we do tall this texture over our terrain. So I've just chosen a bit of a green and Dr Green, which is going to give a bit of a cartoon effect. So just creates, um, random radio grating chair. And they will describe her to fall export and quick exporters. PNG. Make sure to the Save it to your Project folder, your units appropriate. Colder, which has the textures older. So I have not said what texture into my textures folder and all. We're going to actually create a material which we can then apply to our terrain. So go into the materials holder and then right click create and material. I remember I called us around one of the beckons our graphics and textures folders to see that everything is set up correctly. We need this to critics plot, default and texture shape to D, and we want Teoh actually bring this down. 2024 racks, eyes and hit Apply said that we don't have extremely large overhead wing applying a texture because it is only 1000 interning for about 1000 24 pixels. Tomorrow beckons all materials. We cannot our ground material and in the Albergo we kick on this little circles here, and that should bring up little select texture box like this and we will select across now going back into our terrain. You know, just one Teoh, add this to our measuring Durer. Just take your ground material and drop it in here. And this is now applied to our mission. Under a ritual can be applied to our actual terrain to let it play and see what this looks like. So you can see it's, ah, a little bit of record, teeny looking type of terrain. You can obviously changes in where you want by introducing the principles of graphics in or textures. You maybe deal but more grassy effects by adding some gross pixels in your textures planning that'll just create a different effect entirely. So that's it. Rule this video. See you in the next one. 9. Blender 2.82a Modelling a low poly tree: So this video is just to help those who have upgraded to Blender 2.82 a, which are struggling to model the tree. So what I'm going to do is just take you through the process of using blender to point to A to model our tree. So what I'm going to do First of all, just click away here and we'll have this basic cube to start with. It's going to turn on my screen cost tool so that you can actually see what I'm typing and pressing. So as you'll see now, we can view that. So next thing we need to do is just go over to modeling. Make sure years you on it. It's mode, and you've got this box selector tool selected and simply right. Click and drag over these four verte sees and anyone to right click, and you want to go down to merge courtesies and click on at center. That creates a permit for us, which is the basis of our tree. The next 312 press the a key to select all, and then let's just get into a bitter view by using the middle mouse button and now pretty shifty to duplicate and in the Z key to move on the Z axis, moving to appropriate place, then shifty again to duplicate again and in on the Z axis moving again. So now the next thing is, we need Teoh. Create our trunk. So to do that, use the middle mouse key to see the bottom of our tree every here. Now we want to go over to this face electoral and just left click to select that face. Now you want to right click to subdivide, and then you'll see. There's this option down here. Just click on that and in change this number of cuts 22 So you'll see there is an hour, this metal piece, which we can pull out. So with the face electoral still selected there, just left click on this. It's E to extrude and then just bring this down. Now we can have a look and is our basic tree, which we can use in our game. So in the next video, I'm just going to show you how we can texture this and use the texture paint tool in latest version off blender 10. 2.82a Blender texture painting our model, create materials and exporting to unity: So let's now look at how we can paint the texture onto our tree so that we have our full model and texture created, So the very first thing we want to do In order to do that, we want to just unwrap our tree. So the first thing you want to do is just press the A key this to select everything and in right click to go and unwraps a UV unwrap faces and in on breath. Actually, what we could do so drawn to you smart UV project is to give this a bit of a margin as well . I'm going to just add that in an area white. Okay, And then let's go over to U V editing Z and I can see that we've unwrapped each piece off our tree over here, and we're going to just start grouping them so that we've got, well, leaf oceans off our tree in one place and our trunk in another place. So to do that, is we just going to use the left mouse button to move all of these over and then you press the geeky to move them? Why not to select all of those birth disease. You keep to move this over here and let's move. Another one can also zoom in with the go of the old mouse. Just to make this neater and easier to texture will just group everything that's going to be more or less the same color. That is that over there now that we're here and so on. So I'm just going to very quickly do this. Its own doesn't have to be precise. There's a very like Polly tree. You are doing more advanced models than you likely would want to just improve how you do that. And then this is also going to be green because that signifies this. But at the bottom off, a tree of luckier if we kick on that, so that's that portion. Chris again, just select all. And what we want to do is, as we can see, these are those sides over there. So we want to group them as well, key again and and and the energy just to make it out there. These pieces ever here we can. The key is a wreck tight key by pressing our title to fit that, and in Christie Key, some of these art irritate. Find out more or less like that. Kids you're and this one. So it you keep over here a Z We saw that this is part of this portion off our tree. So want to move that into that same group? And in these portions are this little bits under our greenery? So we want to move them also into this block over here. The something Move it over here and then leave them bus over here. How it can actually live this closer to here. And now you want to just go ahead and create a texture. So to do that, I'm just going to click on this new button and just okay, I could see we've got a texture which we can use now. It can move ever texture paint. Now it's just this purple color. And here we want to just select our image, and then I'll be here. You need to make sure this is on texture paint and in the sticks, her slots. We want to go and lick on single image, and then we want to click on Entitled so that we have this elated. Well, if we paint over this you can see it's painting onto our texture and also onto our tree. So what we're going to do here is just a very simple paint. Are the greenery we're going? Todo strew some green color. You can choose whatever color you like. Now it is painted in the section and you'll see it's applying a tall tree on their writing . That's murder six that and then our trunk. We want to make a brown color. So bearing to the rids over here and however this we find a nice guy, she sprouts That's fine, said then all painted over there, and that's going to build no country. So that's it for the tree and text a ring. So the next thing you'd want to do is toothy export like we did in the other videos in the series. It should be some litter to that. Use FB X. Then you can just go ahead and can use their mental transform scale of one. And I think this Z forward just experimental that. But we don't want all of these items. Want to get rid of camera lamp amateur. We want the mish and selected outlets, the guide and exporters that as an fbx, and you can start using it in your project. Otherwise, by I'm going to be including the assets off everything that I use in this course so that you can reuse what I've created because we will not be modeling. All the buildings will just be modeling this one tree. So doesn't a blender course, but it is, Ah, unity course Mitchell teacher. Hard to create the basics off building a city builder game. We'll give you most of the assets in the course itself. Thanks for watching. See in the next lecture. 11. Modelling a low poly tree in Blender: So now we've got our terrain generated and got some materials and textures for our terrain . Now we're going to move on by creating one of our three D assets for our game. So we're going to be using application called Blender. It's free for three D modeling and then from there we're going. Teoh texture are tree and also then create material and in bring our tree in communities so that we can start generating a few more items on our terrain. Procedurally. So let's jump into blender and model this tree. First of all, we're going Teoh have our standard cube when we started the project and then head over to edit mode and then going to select Bill, take select and beginning to hold down shift and just like the top with disease. I love this cube. We're going to you head over to you Ramesh menu and go to courtesies and click on merge. The native moved at center, which is been going to give us this shape, which is the first part of our tree going to hit the A key to select all shift the to duplicate France Idiot Z key Teoh, keep this on the easy access. We're slash you're gonna move it up. Really, It is to scale on. Bring this down slightly. Unit City again. So you create another copy. Rizzi Teoh, just on the Z axis that's like him with it up. And when it scaled again just to scale, it's likely down round, for a actual tranquil begins is just rotate to the bottom part of our tree. You're going Teoh. Click on base selection mode and right click on our race winding Teoh Press Control are to create a loop cut and we're just going to scroll amounts up once and hit. Enter interrogating just to confirm. Then again, we're going Teoh Chris painful or again to do another. Luke cuts on the other excess and scroll up. Create two new cuts is entered and enter again. Now face select. Begin and select this middle face in a press E to extrude and Z Teoh extrude on the Z axis , the stranger pulls down slightly and click. As you can see, we've got a very basic like Polly tree, which continues in our actual game. So this ends off the first part of this video, where video section where we're going to just create this street. In the next video, we will be unwrapping nous and creating texture and material so that we can actually paint this to look a little bit more like a tree. See you in the next one. 12. Blender texture painting our model, create materials and exporting to unity: better one. So now we've got our tree. Welden Linger. We need to now start picturing it loses its really bad and we want to make this actually isn't slices possible So everything to do to get a texture is mean. Teoh, perform another app. Unwrap is basically like when you unfold a court box and I had flat on the ground. So essentially our three nations grants feed unfolded and also be put like flat so that we can painted into the space. So I wanted to do that. We need to just make sure that on the right inside there are cute convicted or are actual tree object. And in you, Teoh do the the mapping and I'm going to check on Smart You project. So what I like to do is City Island margin because what this does is when you do unfold all these little triangles, we want some spacing between them. And you don't one thing to actually attach to each other. So I'm going to sit is too nice, comfortable one and family. It's okay. So now in the top right hand corner, you'll see this little arrow trick of that, and great, that's and left. But now for two minutes and we want to house tensions to the engines are still that we go down here and check and 30 TB in genetics. We'll see now our entire race laid out Trini Space. So listen, I want to do here is I want you fistful speech over into do it alone and they want to travel into teacher paint on. You'll see that there is this cane slot. Jeez, is it three? It's OK was in options black on it should not be available in here through the end. Solich of tree texture. And this is a lar on rents triangles now along this texture. So service, which is going to have sex in mutual parents of immunity and safe. And we just fancied safe rights. And I've got our 6% production ready to paint all this pain. It's just going into textures, says a treat exterior, and six year was made through any of one treats, and that's if you don't see this portion. What you'll need to do is this time might be something else or man, so you have to go down to image or moving. That is her for these steps. That should be fine by default. But I shouldn't see this. You guys not in down years insecure treat, texture Okay. Said it's allowed in materials. We just need one thing here. Just me. Really? I'll chill to something for you Sports the Celtic our interest repayment ever here. And this is just decisions to paint it as well so that we can terrific that open up our payment options here. So just just off the green, because most of tree is dream as a base color And then from there began t color in our box and being just looking model and just do some touch ups green like so we're gonna go in there. It was a strange is sometimes hard to fill ingredients, Elsie and well seeing over here Ah, whole trees are being so that things are things that she looked at these little rectangles , these mushroom prison walk of the tree. So it's an excellent It's like, uh, was this text wall what's gonna consider color here and going to a brownish color which, like this'll look on and make sure your strength is once people present issues down 35 should be sufficient for us. So we're just going to paint over was Rectangles. Well, this is important step. This is part of its that scares. Okay, let's now look at our six years true. Kansi. Very welcome calls are light sources What China Directive Island. So I can't do you just interviewed by Lansley's. So again Teoh Likely a lot of the empire. And since they are land one country and up, the spirit of brightness surrounds. Do you see it? Screamed. Blood in small are popular. It's like right, right, So now the list thing going to be playing is going to explode this for immunity. So that is one of two things which might get tricky. Here It's that rotational R J. Because of re sizing, might not be standing. Yes, that begins after you do some changes to our actual years off our object, but I'll take you three left and just explain a little bit. So there. Well, I understand exactly what's otherwise. What's going to happen is size and irritation of our models is not committed crimes, and we need to get the drive for our terrain generation. Waas trees are going to be spooning very good way on our map. So let's just because that out serving today in object mode and this is, um so lowering Teoh change the skeleton irritation. They're here to see their organs. Options. In this case, we've done some interesting things to see the mention to you 2 to 4, which is fine. But also scale is one long, long while which spreads. So what often happens is that this it's modified and they are. Trian are seeing immunity will love him. They cried because this is the first on two or one or whatever the case may be, because we fall in the right process in beginning. This isn't necessary, But if you have todo actually do this modification being your gain since do go into object and apply, and you need to go into rotations and scales and you just make sure that doesn the street boxes are selected. And next ball that sit up your mild So the next thing you need to do is we need to explore that it be excellent, became brilliant into unit these loans, and this creates, so we're just going to say it was it. It's on here in the sittings. We want to you kick one spirit momentum. Because girls, one we want you has lifted objects only because we don't want to bring in the land of the camera. So we're just going to bring Mish. I have been keeping those on Then should experiments addicted shooting exported? Practically. So listen, export that it be it's and thanks. God says it. We've now able to export our tree and cannot important institutions. E he doesn't. 13. Import our tree into Unity 3D: right. So we have now modeled our basic tree, and we need to bring it into unity there. In order to do that, I'm just going to create a new folder under the graphics folder we created in earlier videos, and I'm to call it models. And then we drag our basic tree fbx into our models folder to go into that folder and then just go onto tree material and make sure that your actual textures are applied. If not, then make sure you bring your texture into the textures folder back into models and tree material and actually drop your texture in the in your tree. Should display curricula is drop a tree into the scene. Just have a look at how it actually looks. There's just something we want to do just before we hit player. Just to look at how are seen looks one Teoh double click on our rain. And when a player to see where our terrain is in relation to our actual embarass, I'm gonna move my camp or my seeing view over like this and I'm gonna click on main camera . I'm gonna go down. Teoh became objects menu item, and I'm going to say a line with view. They will see now our camera preview. Actually, slaves to that I wouldn t do stop the play button. We're going to lose our camera transform. So what we want to do is just go over here and click on copy components up that play and you'll see a house reset our camera. But we cannot right click again and paste component values to set up a camera view correctly. We can hit, play and have a look at how this looks, and this is what looks in the game use. Our tree is not completely off enter from our world. But what we're going to then do is we banked zero the South's and again that tree is now off to the left. Here, going to now start with the lining of tree to the world. It's about halfway from the top or bottom there. In order to align it to the world, we just going to push up tree at by putting five of a ratio on the Y axis. It should more or less almost lineup. Not quite yet. This one's it, but you'll just play around with these values and told, You've got a tree that aligns to the world. I just have a deeper look. Just make sure that it's or less there. My week just even drag it up just to get a better idea exactly where it should be. This is actually 1.23 so we're going to set up tree, too. 1.23 on the Y axis. That's important for us to first the line of tree. You are actual terrain before we start spawning a tree onto our terrain. This is the end of this video. In the next video, we're going to be adding to our terrain generator script to allow us to generate trees on our touring. 14. Spawn our trees on our terrain: the great guys. We now have a tree and are seen. And we now want to start changing our terrain generator script to allow us to start sporting some trees on our touring. So I'm going to hit over to s it scripts terrain generator and I'm going to open this up in visual studio and we're going to start adding some code for generating out trees a Z weaken . See, last we left off with just creating drama tree for our terrain and also just playing some pearl annoyance just to give it some variation. Well, tree generation, we're going to need a few variables, so the 1st 1 is going to be the public into number of trees. So this is going Teoh, a lower inspector, to be able to sit the number of trees we want to generate. And then there's going to be a public game object called tree. Though this is just going to be a slot in our inspector where we can drop our tree prefab so that we can then go and generate, and instead she ate the tree objects. So in order for us to start generating these trees, we need some methods which will help us with getting random points because we're going to be randomly generating this rain. The first method we're going to be writing in something called Get Random Point that's going to return a victor three and don't call that get random points then will basically look at our points, which were generated far terrain. So we'll take return points and we're going to do it in arranged. The first value real GOP, while the values were going to be passing in his A range between zero and are number of points are in order to get that going. Teoh. First of all, just call random dot range. We're going to be starting from the zero point, and we will then be going from X plucks multiplied by Z blocks. You get a total maximum number off wins that we have, you know, points array. Then we want to get the nearest great point. In order to do that, we're going Teoh, right, a method called nearest grip point as public void nursed apologies picked three that we're going to be returning and it's called nearest point. What we're going to be passing any is a victim three points, so this will be a point. We were going to be morning any object in our scene. So when we do get to the point of starting to place, objects of mouse clicks will be using this method again. In order to do some mapping to our grid, we're going to require during some mathematics you applied to our actual random points. In order to do that, they're going to have it in X point. The reason for integer is that it's going to then rounded off to the nearest whole number and we're going to apply, if not floor. That's Ah, the case, and we're going to take Point X and re going to do the exacting with the access. We're just going to replace this busy and so will not be applying anything to our Y point because we are a scene she's going. Teoh never change the height off our items. It's going Teoh always try and be fixed to out to rain. So we don't want to randomize that you could If you feel really wanted to do that, you could, But, um well, this a lot of game. We just always want to place our items on the terrain at a specific point on the Y axis. The next thing we need to now just do is we just like to return and New Vector three and it will be explains. And for the why will just put one hypothetically for now, it contests that are too little later to see if it were express and that will get us our nearest great points. The hard work is it basically would bring it down to the nearest lowest number and then make sure that it is a whole number where these points could be anything that is like a decimal value There. Here we gained two converted to whole numbers so that it snaps to our grid. The next thing we need to do you need to actually start building our if it for generating a treat. So this is a very simple method. There's public Boyd going to call it generates these. And the first thing you want to do is because gonna make sure that the three the object is populated in the inspector. It isn't always just going to return and do nothing. So we avoid any errors and also if there's any inefficiencies we can this over that were actually in Stan Shih ating anything next thing we want to do is just to care, Tink am object. And we want to declare a spawn point that this is very gains this morning country, that's a big city. And then we just want to start looping over again. T spot from I equals zero and isa less than the number of trees which we specify an hour, inspector and be increments by. So this is where the actual magic happens. We're going to know a sign temp game object equal to instead initiate This is just basically going to create a copy of the tree object which we have dropped into our inspector and I really want to get a spoon point and we're going Teoh enemy generate a spoon point. My first calling nearest good point. So that's going Teoh wish our endpoint to the nearest great point and then we're going to just old gate random point. So then, just to make sure that our tree sits correctly on our terrain, we're going to set us form point about why equal to that 1.23 blood value we had in the previous video and in temp object is simply going to be transform is going to be set to your position off the spawn point. That's almost everything we need. We now just must remember to call general trees in our start method of our script trees, and now it can actually hit back to unity and start doing some set up. You'll notice if you just click play, nothing is gonna happen at this point. That's just a blank terrain that what we need to do now is we actually need to click on terrain and we need to drop our pre model or prefab into our slut. They'll see as a tree game objects lots. Drop that in there and we need to sit on number of trees. Start off with 100 and it's a look and you'll see that generates a nice little forest for us. And I'm just going to then remove this streak. We no longer need it. And guys, that's the end of this video. We're going to look at the click and placing objects in the next video. Thanks for watching you. See you next. This 15. Setup Unity 3D project for object placement: Okay, guys, there. Now we've got our tree Sit up And we are spoiling trees on our terrain from our last video . And we now going to start looking at setting up a bit of a script and doing this little bit of configuration so that we are in preparation of starting to play some objects on our terrain. The first thing you need to look at its visible on our terrain in 12 game object that we created in previous videos. We going to make sure that it is tagged as to rain Object. If you haven't done this and you don't have terrain object yet, you can just go Teoh tag, and then you can click the plus sign and created during object tag and in just simply assigned the tag on your terrain, Teoh terrain object. So this is gonna help us? No. When we've actually hit, like a point on our terrain there for the very first part, we just going to you right and basic. Oh, just to get an idea of where we are actually hitting the terrain with our mouse pointers so hard this works is it's going to be and array, which is going to be taken from our camera point down to where our mouths point is, and then we're going to convert that into world space. And then we will be able to then know where we've clicked on our terrain and then be able to place the object there. So I was beginning to do is we're going to just create a new scripts of Again Garbett essayed scripts and we're gonna create teashop script called Mouse Pointer. I'm going Teoh openness up being visual studio so that we can started working on this constantly click reloadable here so you'll see. We now have our mouse pointer script. They're one of the first things we want to name just the finals. We want to be able to define which camera we are going to be using because later to talk well, videos, we're going to be adding a second camera, which is going to help us with our many math. They're in anticipation for that. We're going to you just start by creating camera, so we're going to have a public camera which will soon be able to assign in our inspector, and we're going to have a right cost hit. I'm just going to call hits. Going to have a ray. Well, gray, not rats. Right? And now start method. We're not gonna be doing anything yet. Will using that later for populating our game objects? The first couple of things you want to just do in our update method is we want to. Instead, she ate the ray and I'm going to use our camera. And she is a screen onto the screen point Toray. And so that we're going to put our mouths position. This wouldn't basically give us a ray cost between r camera view. Well, camera sits and where are Mouse Pointer is actually on screen? The next thing we want to do is we want to actually thing just check if there was a ray cost hit or not with our terrain object for that, we just going to you have a statement and going to court physics. Not great. Cost the building pause in our ray, which we doctors created from a camera view and our mouse pointer and we'll Pawson out it. That's an hour. Looking to you really do anything here? Maybe we'll just at a maybe a d bag so I can maybe see something will draw a rave, maybe. And let's start off with the right origins. Let's play. The great cost originates from So that's going to be our camera. And then we're going to draw the ray in a direction and we just give it a magnitude of a lot of 2000 points on This was like the color of green that we can yet and the system going to be the duration that we're gonna be and we're going Teoh six that tous to false. Okay. I mean, obviously inside your we want to do some detection of if we've actually hit the terrain or not. What? We're going to do some things. Haven't statement object? That is it. Tag bag. They hit the tag. Yes, attract. And it must equal are terrain object. Just keep that as a template. The main thing we really want to actually look at your is are mouse button inputs. So you're going to have a right click and the left click. The left click is great. Basically place down our object and are right click is going Teoh destroy this currently selected object that actually just fall this video. I'm going to remove this first because I just want to get past the input stage and actually won something which can run at the end of this video. So the first thing we want to do this want to look, if we've got a mouse button looking priests, the mouse button down and we're going to be looking for the zero of Baton, which is basically our left click, and we'll happen else for inputs. But big mouse button right click. I just wanted to show this off. Thank Teoh at a D bag dot long. No, they here, right, but new kids and we're going to have you back that log lift. That's just basically the template to start off with real in the next video, probably. But with the sporting an object and going into more dips about the rate costing and those things they are, the next thing we need to do to just get this working and set up is we need to create what we call a game manager. We'll go over to unity again and will create an empty object, and I'll just read named this two game manager and we would want to sign script. The said that it will always run when in it she starts up and we're going to sign our main camera. Did the camera here. That's just a dragon. Sea of everything is fine and we should see left button Click. If we say click the left button, click the right button, it should take right button click. That's for that's it for this video. Just to get some input from our mouse and set up our game managers. Are you sure that actually functioning in our game? So you guys all you in the next video and we'll start looking at placing at least one object in the next video? There's. 16. Importing our models and materials: Hey, guys, welcome to this lecture where we're going to be bringing in some of our assets into our scene. So in our previous lecture, we were looking at the script. We're going start placing objects on our map. However, we need to first go and just bring in some of our models. So if you need to get the models, you can go and download them at this link over here in the project description for the course. So you'll see. There's this kid s, it's here and the standard link. Once it's downloaded, you should have a graphic start zip file, which you can then extract into your project, and that is essentially going to give you this graphics folder. So let's start off by bringing in RS. It's so that we can start putting them in our scene. So the first thing we want to go into his models over here and we want to bring in the Big Rock, the small rocks, skyscraper and power station. So just drag those into the scene like that, so you will see they are pre fabs at the moment. We want to just get them out of pre fair mode so that we can go and create new pre fabs from them. So just right. Click your anger. Unpack prefab completely so and I'll see they're just regular game objects, which we can manipulate. So describe your mouth your so you can zoom out a little bit. And what we're going to do is just create some materials for the So let's go back to graphics. Go into materials, as you'll see that is just the ground and the basic tree material at the moment. So right, click, create and then go to material and lit. Call this rock material and we're just going to use a basic great color for this that will do choose whatever color you'd like. The rest of sitting should be fine for this. So let's just click on the small rock and just drag it onto the actual object like that. And then the big rock licious movement over and applied like that so you can see the color has changed ever so slightly. Next, let's look at our skyscraper, which is this basic building ever here. So Teoh apply that texture. We could simply go into textures, and we could just drag this building texture onto there and you see it supplied next, This little power station model will just drop that onto there and there we have our little power station. So let's now bring these in this prefab. So go over to your S. It's folder, right click and create a new folder Cool pre fabs on. Go into that and then we want to go and just click and in press shift and click again and drag these into pre fabs. Actually, I think you can only do one at a time, so maybe just do that. And then, as you can see that I've already got their textures now applied to them, and we can just bring them into our seeing at any time. So there's something we just want to be sure off is that we have got zero values here. So let's open each of these pre fabs and make sure that position is zero. Why's there? NZ is era. Let's go over to the next one and make sure the exact same thing applies zero zero's. There are, and in exact same thing over here, so that's ready. Zeros. Open it up here and like it zeroes there. Zero. And there we go. We've now set about pre fabs, Teoh, all the at the origin. So great, guys. That's what we needed to do to sit up our assets in the next video. We're going to start with some basics for trying to actually play some of these objects within our scene. We make look at random, generating some bar rocks on our terrain as well, just to give it a bit more to to look at. Because moment it's very basic. It just has these trees. So thanks for watching. I see in the next lecture. 17. Basic building placement,start placing buildings: Hey, guys, welcome to this lecture. In this lecture, we're going to start off with very basic building placement. So let's start off with the complete basics just to get our right costing working. So let's start off with a variable called Public Game Object Selected building. And then we'd temp object, which we can use inside of our script. So I'm just going to called TMP O B J. So what we going to do is on our mouse button click, which is our lift click we're going to then try and place the building. So here we've already got a camera, which is using the screen point toe to Ray, which is on our mouse position. That's in to take it from a camera view down to where our mouths position is on the screen . Then we send out array cost With this physics start Ray cost and we get this hit point so I will use this hit point to try and place are building. So the first thing we want to do is just Instead, she ate our building into a temp object, so this is equal instance she ate selected building, then the temp object not transform the position. We will say to hit Point, and we'll save that off and head back into unity. Here you'll have your game manager, which you previously have set up, and you'll have this mouse pointer script. What we want to do is just bring in an object as our select the building. So I'm just going to bring in this power station. So do you see we have an error here. Let's just see what that is. So that's lying. 37 strict that out. It's very selected building. Was this the same? It is. Okay, let's just try and ran this and see if the text does work or not. Run that and it's loading. So essentially are selected building should I'll be our power station. If you then click on your terrain, you will see that it is placing it away. The mass point areas. So, guys, that's basically how the very basic positioning and placement is off these models onto our terrain. At some point, we need to allow it to not go through the floor like this because that doesn't make it very realistic. So in the next video we might just go and tackle that and in just fix up this issue is going through the floor. And maybe also add a particle effect in the next few lectures. Thanks a lot, guys. Thanks for watching. 18. Fixing the building placement and snapping to grid: Hey, guys, Welcome to this lecturer. So in this lecture, I'm going to fix this issue that we had from the previous lecture where when you place thes objects, it's going through the floor. So how I solve this is by using unities physics engine to help us do the work. So let's just go over to this power station Pretty fair, pure click on open prefab and let's start off with a rigid body. So this is going to start to apply some physics to our object we're going to later. I have some constraints, but I'm just going to show you how this works. I'm relieve these orphan l and then we need a mesh collider and we need to make it convicts . So you'll see that it is now applied a collider to our prefab, and we should now have some collisions with our terrain, which already has a mission collider on it. So let's play this and see what happens. So this is going to be a very interesting little effect. Now, as you can see, our buildings are bouncing around on our terrain. So to change this and fix this, what we need to do is go over to our power station again and then just freeze ALS these positions. So what, this will just do? Does this make sure we can't move in this space and it is just a fixed position so you could see the complacent objects just fine again. But still, we have that issue off it being in the floor because the mouse pointer is essentially putting it into the floor. But the object center or origin is in the middle off the actual model. So in order to fix that, to be going Teoh, then just go and apply some changes to our script So you could expresses back button and open up your scripts in visual studio again. And we can now just modify this to apply some logic. So one of the other things I want to cover in this lecture as well is to snap, are building to the nearest point on the grid. So how we can actually achieve this is if you remember from our terrain generator, we created this nearest grid point method, which estimates the closest grid point that we can place on on our terrain. So I'm going to add that because most of the city builder games we build in blocks, we don't just place it at random positions. And later we're going to need this to figure out if ah, building is already in a great point or in a block on our terrain, so that record place other buildings in that same region. So let's start off here and let's just get this nearest point in so that we can sit our position. So to start off with what we'll do is we'll just create a nearest point. So will go on. Creative ate the three cold. There is a point, and then we need to go and get that component from the terrain generator so we can say game off it that fine and we confined the terrain. So what we need to make sure off here in our unity project now is that the strain is actually cooled terrain. Ever hear some? Actually, you've named Terrain, and then we confined it, using that name we want to use get components and we want to get our to ring generator script. And then finally, we want to get in their script point. So are hit that point and it's become our new point, which we're going to use to position our object. So let's just go and do that. Temp objects are transformed that position, and we now going to be sitting it, actually not with that position going to sit position and rotation to make sure everything is fixed. And then we're going to use. And Lou Victor three, and will use on airs point Plavix on our nearest point. But see, but for why? We going to use one so that we can just left our model at by one unit, and then we're going to throw nears Point Z and then our rotation. We simply going to see it what it is right now at this point in time. So transform doctor quotation. So let's say that off and see how that works. You'll see we are now more or less almost placing this on top off our terrain and see there's a gap there. So what I want to do as well as I just want to go and modify the script a little bit more, it's maybe you make this two units just to show you how we can affect this will be a play and play and repress, and you see it's now basically hovering on our terrain like so Now what we just want to make sure of here is that our actual power station can move. So what we want to do is just maybe unfreeze this positioning so that it could move downwards but not rotate. So let's go back. And this Run this again, Castle. Let's just modify a few more things. This make sure I'm using the correct corner to open up the prefab. And let's might be the why that we need to look at Felix at this units on how they work. And perhaps Z needs to be Fresen. So the coordinate systems between blender and unity or someone difference. And now you see, we place it in the air and it falls down position itself on the terrain so we can make this a little smaller so that it there's a lot quicker, so trains it to 1.5 and then the physics engine itself. We want to just add a lot more gravity to this, that it falls a lot faster, so we're going to remove the drag and going to change the last 100 and then this. Run that and see how that looks. Garden area argument to cannot convert from double to flex. At least see what that is. It's because I forgot to pretty, if here, to tell unity that it off let just fix it up and it's run with this now. It's trying place, so we'll see a places almost immediately and drops down to fit our terrain. So that fixes the issue off it, not fitting on the terrain correctly. We will later add some fix and everything said that it doesn't look so obvious, and we could remove some of the shadows just to take away this little bit of this cap that you see under the building. But that's it, guys, for this lecture, that's how you place objects and get them. Teoh not fall through the floor like that. It previously thanks a lot for watching guys check you in the next lecture 19. Camera scroller,scroll our map with mouse: Hey, guys, welcome to this lecture. In this lecture, we're going to be looking at how we can create a scrambler Silicon Scroll are screen or are terrain based on our mass position. So in city builder games and all tsk sort of games, we have this scenario where we can scroll by moving mouse across the screen like this, so it's quickly implement this. It's, Ah, very basic script that we use, and I'll explain it along the way. So let's go into script from RSS folder and in Right Click and create Teashop script on it's called a camera Controller. So how this is going to work is it's going to look at where our mouths position is, and then apply translation to our main camera to move our main camera in our scene. So if you remember, we use our main cameras position and do array costs down to our terrain to place our buildings. So it is only logical to move our main camera around when using the script. Let's go over to visual studio and get started with the script, so it's open up camera controller ever here. We're going to get rid of this start method, we're not going to be using it. Let's declare some variables of public flat scroll speed. No, this is the rated, which we're going to be scrolling our camera with our marks, so just going to make a 70 float as a default. And then we're going to declare public int padding, which is going to pad out our screen with a value. So how this will work is if I just go and run this unity project again. So when our mouths surrogates to a point here where it is five units away from this border , it will start scrolling. So we'll do a check. Donald these different borders to see that if we are within five units that the screen will start scrolling and moving a camera around. So let's head back to the script and just work on this logic. So the very first thing we want to add here is just getting our mouths positions. So let's just start off with a float, a mouse position X, and we get that by using input. The last position biotics. Then we want to get our mouse position. Why? Same thing here. Input of mass position thought, Why this time? Now we simply want to do some logic to do. Just check where our mask position is, and then move off camera appropriately. So the first statement is gonna be an ex statement, and we're taking our mouths position X and checking where is less than our padding. So where this is going to be is on our far lift. So when we get all the way to this point, are five units away from the border this script, Aled, and pick that up and start scaling Our camera said what we're going to do here is being to take the transform, which is the transform off the object the script is attached to. So that's going to be our camera going to translate it translate just means move. And then we're going to use a victor three daughter, right? Have you hover over this? You're going to see that? Is this one in the exposition? So we're going to be scrolling on the X direction? No, because we are moving left. We're going to have a negative scroll speed because we are decreasing are right or exposition. Multiply that by time. That delta time to just keep this frame independent. What I'm gonna do is I'm just in a copy of this to more three more times because we're going to be applying some similar sort of logic. So for X now, we're going to be looking at the far right over here, sir, to apply that we need Teoh. Just simply check if it is greater than or equal to. And then that's going to be the screen. What's we can call screen not with and subtract are petty. That means if I mask, position is great, too. Then with this position minus all packed padding, then we'll start executing some instructions. So translate in this case is going to be the exact same thing, except not in the negative direction. The next thing we want to do is you want to look at our why just change both of these two y positions and here we're going to be looking bigger than and less than or equal to for now . So this particular one is Look at it. It's going to be when we are at this point and we are five units from this border. It will start executing a script again we're going to be transformed or translate. Except now what we're going to be doing is we're going to be using cameras transform because cameras basically suspended in the air and we don't want to move it across the terrain per se. We want to revert across its excess. So if I had to show you what this would mean is that can see that it is slightly suspended in the air. So we want to use the position that is basically moving across. Thats plane over here, so I need to move in that direction, but not down here. Otherwise, that will cause issues. So we're going to use that exact transform. Teoh do that scrolling for us. So what we'll do is instead of Victor three, we're going to use transform and we Antaeus forward. Apply that and then simply in this statement, to be going to be looking at the negative or the bottom portion here and the padding there so it needs to be less than or equal to the screen height, not height, minus the petting. Simply again, What will do here is it's going to normally in the positive direction, and we're going to be using transform, and we're going to be moving in the forward position or direction rights. To save that off, head back into unity, click on your main camera and just crack this in. Never hear Sinai Seacon Ultra Scroll speed and you're patting if need be the trend. This even works that does have a weird zooming effect. I need to check what is wrong here with this. So the left and right is working. I just have a look at what's going on here. Let's just place a camera and, uh, more reasonable position. Zero. Let's take off reputations and let's see if that makes a difference. If the school left school up, that seems in and out. So that's what we looking for. So let's just position this. No, we want to, and we just put our main camera at a tilt of sigh. I think it's 4 45 degrees on that to be on the X axis to see what this looks like. We're going to have Teoh just play around and see what this looks like. The screening left and right, works that's not exactly working. Just get out of full screen mode. So that we can do somebody bagging you. Just click on this again. You can maximize here and in play over here. Okay? Really? All. I just want to keep an eye on this guesser zooming us in smoothing on the X. Only this is moving us on Z and and why? And it's just modify our script a little bit. And this Have a look at what's going on here. Scrolls be time, Delta time padding. Uh, screen height. It's all fine skillet regard to maybe use up here in ST up is going Teoh, give us a different co ordinate eso that's increasing some stuff. Okay, right. So I think how we can fix this is we need to you just revert that control Z. Now we need to go into main camera. What we want to do is take this rotation off. We are now facing the terrain, so it's going to look like this and scrolling would work. But what we want to do is just elevate our camera slightly in. What we want to do is we want to change the look at position so there will go into game object. Everyone moved to view will align to view and let's have a look. That looks like so that looks a little bit different. All right, we need to bring this up further, huh? Hit play. Maybe a just hit back when we can play around with the stool is to have a look. Everyone pulls this, then what we want to do to make this zero Just look at where we are. So let's make this 45. We're looking down. Position will leave is is scale will leave us is well, uncheck this Aceh's living in an art. Right and left. Um, this is only moving on the y axis at the moment. Okay? Which is what we want. We just want to know Change the direction we are moving in silence trenches to up and change this to up from this again. Eso It's not gonna work now because we haven't fixed our direction here. Want us to be 45 for this to be zero and we want to run that that were on going forward and back, as you can see, so that fixed it. So now they regard guys, you cannot scroll your ah terrain using your mouse and you can obviously just go modify this. So maybe you want to just invert this direction here, so that doesn't seem right. So let's fix that. We're just scroll speed in the negative direction for this one and positive direction for that one, and then go back and then run it. That's forward, back, right and left. So a lot of this is that going to take some trial and error and why I'm actually showing you this life and not just copying the original project it so that you can get an understanding off how to fix this. If you do run into some problems with your Inserra because your camera might be in a different orientation. So you're going to have to play around with some of these values. So anyway, guys, that's the end of this lecture. Thanks for watching. I'll see you in the next one. Okay. 20. Adding our rocks to our terrain: hither Welcome to this lecture where we're going to be bringing these big rocks and small rocks into our terrain. So to do that, let's first go off into visual studio, where we're going to be opening our terrain generator. And then what we're going to be doing is we're going to be using a similar technique to what we did with generating and sporting trees on our terrain. So let's just go ahead and create some variables. I'm gonna use this as our basis. I'm going to copy Lis twice, and instead of the number of trees, I'm going to call this the number of small rocks and a number off large rocks. So there's a lot of different ways that you can actually do this. But this is the easiest way for this, but there and this is going to be a large rock, respectively. So this is just going Teoh tell our unity script. Harmony rocks we want to spawn. So the small and the large variety and this is gonna be our game objects. So let's head down to where we created generate trees method and let's copy that twice. And instead of generate trees, it's going to be small rocks which were then just gained to check for small rock and the number off small rocks over here. And then small rock is what we're going to be in. Stan Shih ating, Same again. We're going to find the nearest group point and we're going Teoh to the spawn point a little bit above the terrain so that it fits on the terrain. Then similarly here, we're going to have large drops and this is going to be the large rock. And this was a obviously being number off large drops. And in simply here, we're going to be using large rock, which is our game, object or prefab, to save that off and in head back into unity. And let's go over to our terrain game object here. So now you will see that we now have these new slots Was more rock in the larger up and the number of rocks we want to create. So, for the scene I have changed this ex blocks if 50 so we can make our drain. It'll bigger. So guide and change yours. Now it's about 50 50. A number of trees, 200 for now will experiment a little bit with that after we've designed our rocks here. So delicious Assign our precepts. So we're going to sign our big rock toe A large rock slot, A small rock. Tiu are small rocks lot and the number of large rocks we want. I'm going to start off with 50 and the number of small rocks we want. I'm gonna start over 50. So let's run that and see how it performs. So it hasn't done anything. And the reason for that is we need Teoh actually call these methods. Sorry. Let's move all the way up to here where we start our scene and we generate our s. It's so I'm going to use the same miss it here, but it's going to be generated large brooks and generates small rocks. So when we call those, it's going to then go ahead and run those methods and create pre fabs. And I'll see you let it play there. You can see they are rocks, skedaddle over. I'll see now, which just gives our terrain a little bit more off a forest feel. And as you can see, we can still place our power station building So, guys, that's it for this lecture. In the next lecture, we are probably going to be looking at a bit of post processing effects just to get this flat feel of this terrain. Teoh. Just be a little bit more interesting. So the guys Thanks for watching. See in the next lecture. 21. Setting up post processing: Hey, guys, welcome to this lecture on post processing. So I'm going to just show you here in one of these examples that I have off the game that I've been creating. It's a first person adventure gang which you can walk around a world where you can describe and do various event requests, etcetera, and do crafting and building. And that's sort of a little bit of the vibe of just survival techniques as well. So what I want to show you And this is how Post processing is actually making a huge difference in how this game actually looks so to show you how it looks before post processing has been applied. Just going to go ahead and run this. I just want Teoh. Just go over here and make sure that I've got this order turned off so that you don't hear the footsteps off the player. So let's run this. And just to look around the scene, you're going to see these. Their grass Every here, which doesn't have a lot of detail, has no shadows. It looks pretty flat, and if you look at it carefully, you can actually just see that it's an image that has been projected onto this terrain. When we look at the trees here, you can really see it. But if you look very carefully, there's also no shadows. Every here and the trees are pretty flex. Not a lot of movements, not a lot of life. And when we look at this little stream here, it's got a little bit of refraction from the sky box. You'll see There in the distance is a bit of a green tent, which is coming onto this extreme, but pretty lifeless doesn't have a lot of light bouncing off of it. And ah, son is pretty flat as well. It doesn't have much lighting. Conceit is not a lot of color coming through from the flares and all those glaze, which you expect to see in a scene like this, sending me to show you what this could look like if we had to go and in able our post processing effects. Somebody here, I'm just going to turn it on, and as you can see, it's got this whole different look. Now it's got this 10 to it. You can look at these trees getting that from thesis son. See that player coming through. We've got more detail on the grass there, some shadows here for going to cut some of the trees. Even here, there are a few shadows which look quite natural, so these trees look a little bit more part of the environment. We've got a little bit low life because they've got different colors and lighting effects bouncing off the leaves. They're heading over to the stream. You can see is quite a bit of light now bouncing off this. And it's not just getting that intent. It's also getting parts of the environments. And if we look here, we can see our son bouncing off there. And the other effect is this motion blur fix. So when we move our mouse around, it's got this blurriness. She is, Ah, quite an interesting effect as well. The other thing we have your is a vignette which can't really see, but I will explain that to you in our course project, and you'll see how it actually can make a difference. So as you can see, press processing can do wonders for your project just by applying some effects. So how press processing works just to explain it is that it goes and applies filters, which are then placed over your camera lens essentially, and that generates different color schemes, bloom effects, etcetera, blurring whatever you are trying to bring into a game. So let's now I look at how we can bring this into our scene, and then I'll explain to you in the next lecture how we can actually start adding some effects. So I'm just going to move this over so that we can work on our scene over here, which is our course project. The first thing you need to do to get post processing going, you need to go over to window and you need to go into the package manager. Give this a little bit of time to load your packages. You can see. Then what you're going to be looking for is something called post processing, and I've already installed my answer. You'll have a install baton over here, So just like that, install root for the packages and scripts to import and post processing should now be in your scene. So then to go ahead and sit this up, we need to go and just go over to our main camera. Over here, unity is being a little bit slower. Just bear with me. It's no avatar main camera, and our main camera is going to require something called a post process layer. So we'll go in at a component ER and will add a post process layer and in the layer that we're going to be applying this on is called press processing. If you don't have this yet, you can just go over to the top here and go to this default. Drop down and click on add layer. Ongoing. Added in one of these user layers. Be here and then from there you'll be able to sign your post processing layer so there's no anti alias ing. You want Teoh for more crisp looks. You want to go for something like a sub pixel and a leasing or forced approximate NTL Issing. So what this does is it just removes. Let's say, for example, this line that we see every here is actually a perfect example, So anti alias ing will make this line look more smooth rather than sir jagged so that'll have be applied to all your objects. With the post processing effect, all go and choose if x a and you can do the same. What? So the next thing we need to do to get the post processing going, we need to go and create a post processing volume. So to do that, you're going to right. Click over here in your scene and you're going to create an anti game object analyst. Rename it to processing so you can call us whatever you like. It doesn't have to be post processing, and then I'm going to add a component called Post Process Volume. And here you want to take is global and you want a guarded and create a new profile. So just to give you a quick overview of how this is working and save it and I can add in effect and go to bloom, and it's just put in a very high intensity bloom so you can see this straight off the bat and hit play. Okay, so it's not applying it yet, So let's see what we've done wrong Lit zero. This art, it's that our volumes are in the correct place. The new pressure processing just enable all of these and see how this looks anger out of this maximize on play in terms of that, and then we can just troubled us on and off to see if there is a difference. Eso it's not making a difference yet. We should see why that is. Um, we just got pixel and high quality. And then for our volume, we just need to make sure we've got it's on the right layer as well, because otherwise it's not going to show. Okay, so that's where the mistake is. Make sure that this layer is post processing and then hit play. We'll see. This is glowing a picture. So if we go and disable this, see that it actually makes a difference. So this is with it on, and that's what that off. So, guys, that's basically the end of this lecture. In the next one, we're going to start just applying more effects that we've got a better looking to rain and seeing Thanks for watching. See in the next lecture 22. Adding post processing effects, fixing the camera, stylizing the scene: Hey, guys, welcome to Part two off the post processing lecture where I'm going to start adding some effects so that you can see how we can improve our game seen just by applying Zand basic post processing effects. So some of the effects you want Teoh just add to our seen here is we want to get it. And first of all, just add some ambient a fusion which just gives a little bit more depth to our shadows and make them look a little bit more realistic. So to do that licious first, start off by just removing this bloom every here that we added in the last lecture save our project. And then we're going to start by adding effect, going to unity and clicking on ambient occlusion. So what we want to do here is we just want to go ahead and enable all of these options, and we want to bring our intensity up to about one so you could just type in one over there and in the thickness modifier. We want to maybe leave that one for now, and then we'll just see how that looks. So this is run this and just have a look at what it looks like at this point with this ambient occlusion in. So you can see there's a lot of shadows on the terrain way. We've got River dep. So when reduce and this is from the light that is bouncing off this terrain. So maybe what we want to do is to just play around with this value. So to do that, I'm just going to quickly disable this scrolling script because it is going Teoh Davis propane. So here in on the mouse pointer, I'm going to just disable that. And then that's to see where did we attach the scrolling effect? And that's every here, the camera controller. We're going to disable that we live in a place in the buildings we don't want to scroll, and then we can just look at what we are doing in our C. So we've got a bit of a rough idea. So we've got this new shadows now with the ambient occlusion. I want you to skull down here and find our post processing and let's now go ahead and just play around with this thickness modifier. I could sort of see what it does it darkens or lightens the shadows. What you can do is you can go ahead and modify the color of the shadows. Wells could make a reddish if you want cystic too black for now. Now, the next thing we want to do is we want to add in depth of field, go over to unity and go to depths of field. So this is this something. Give us a bit of a blurry effect off into the distance. So what we're going to do is we're going Teoh. Just make sure we sit our distance at 10. Going Teoh. Keep well, basically move our aperture to 50. No side. I'm about there and in our focal Dean's we want to keep us 50 and our blur size as medium. So you should see if we disable enable this it looks a bit different. I Let's go ahead and add the next effect. Now what one do is run to add something called bloom, which is going to give it a bit of a shiny light bouncing effect in turn on. Everything here going to set the intensity to something I observed 16 and the threshold to 1.1 to see if it's keeping our values are all right. There we go. And then next thing we want to add in a swell is we want to look at adding some color grading. So what? The sculler grading conduced for us is actually give us a bit of a phone type effect. So there is one specific modifier that actually does this for us. The list turned on a wheel here, and then we're getting married to go to places, so that's going to darken apart, seen a little bit. So let's change a post exposure to about one ish that's gonna make a little bit brighter, could make us even brighter if you want. And just to show you what we can actually do with this is if we go and actually move these around, we can actually color are seen and all sorts of different ways, and you can then modify the style of your game to whatever you like. One of the nice things is this you shift you can play around with, and the other very nice one is this color filter. So if you turn this into like a red or whatever color it is that it could provide some tending to your scene as well. What I'm gonna do is I'm just going to turn off thes over here and you'll see that that color filter is also coming through quite strongly. Now you can do some temperature fix. You can make a seeing look warmer. You can make it look cooler. You can also modify the tent of it to be some kind of color. So, Sister, go ahead and reset this. What? I'm going to do this right click here and reset. So then we'll just turn on this mode and put on aces and in post exposure, I'm going to sit to one again, and that's it for color, Grady. So the next thing you want to do is we want to go ahead and added on, yet so unity. And then yet, So now I'm going to quickly just show you what this actually does. So turn that on and then we're going to increase its intensity. We'll see. It brings in this filmic sort of border around our scene, so I'll usually sit this to something a lot smaller. Maybe around here aside, just said that you can sort of see it. And then it's Xidan going to just give you this bit of Ah Foon effect rather than what we have here, which is very flat. So you can see there's a lot more dips now with this on. But the only issue now is that our lighting is not very intense. It's look looking pretty dark. We want to make it a little bit lighter. Maybe so. There's something we can do is we can increase the intensity of our directional light. Teoh. Let's about 1.2. Maybe it's not over exposure to match to light, and we can change our shadows if you like. It's really up to you how you want it to look. I'm going Teoh strangers back to soft shadows like soft shadows, and I want to bring on the strength, the little bits, that there is a bit more transparent, sort of soft shadows rather than such hard shatters. I feel that just makes it look a little bit nicer as well. Let's close it off. Industry ran it just to make sure that it's actually not keep the sittings for us all, hasn't on a lighting, so let's show You do that. Her name hit play. What that looks like doesn't look too bad. And what we want to do is just go ahead and turn this on against the recon scroll. See what the race to the scene looks like. Eso doesn't look too bad. Could look a little bit better. I think so. What we can do to improve this is we can add a sky box so we can go into s it's here. And I prefer to just go ahead and right click and create a new folder and it's called us skyboxes. And then what you want to do is go into skyboxes, right? Click creates, and then click on material and coolest skybox. Then over here on the right, you want to change this standard to skybox and anyone to click on Procedural. What this does is just going to generate a nice skybox for us, which we can use. So to show you how that works is we're going to go over into window. Uh, actually, it's in. Just see where it is again rendering and in lighting settings. So in here, you're going to see there's a default skybox over there. What we're gonna do is drop that in and what we want to do is sign a son source, which is gonna be our directional light. So from here, what we can do is we can adjust the sky box and we can see some changes happen toe are seeing. So it's ah, principle. Just go and disable this scrolling again and let's go over to this. And this is player under these sittings. So some convergence s a thickness. See that It's going to kind of just do that sort of thing. We're spraying. Teoh, make the atmosphere look a lot thicker. We can do more exposure. So it looks very like a door Nora sitting sunsetting here. Maybe depending on which where the sun is moving so you can easily apply that. But what we want to do is maybe go for a blue tint and our instant okay, And then on main camera, we want Teoh. Just make sure that this is skybox and the other thing we want to do just to make everything look a bit different is we need to change the rendering mode off our scene. You see, it's very blue. Me now, but also the equality off the scene doesn't look that great. If you look at this, it looks a little bit choppy and so on. So we're going to do is beginning to grow. And it it's our sittings during the gravity bolt sittings player sittings. And then what we'll do is we're going to change our graphics motor click on graphics and me . Just make sure that it is actually in this section. It's actually going to be in our player section, I believe, and what we want to do is changing color space over here under other settings to linear. So that's going to just change the way our scene looks a little bit gate and play that you'll see these a whole different effect now. So let's maybe just go with most skybox for now. So let's go over to window and let's go over to rendering and lighting sittings again on this. Just say none and this play that see what it looks like. Okay, so it's ah, not looking. Too bad I want to do is maybe just play around with these blue Willis post processing sittings again. So let's have a look at what we can do to just lighting up the scene a little bit more is looking a little bit dark for my taste. So this my front look completely the same as the introductory video. But that's maybe good so that you can actually see how these effects are being done and how we can actually add to them. And you can make your own changes as you go along so that you can make your you're seeing look the way you want it to look. So what else wouldn't do is maybe bump up this soft me over here. That's what it does is it distributes the bloom a little further across rather than in a concentrated area. Diffusion. Been. Think we really want to play with that? The first married? Maybe I think force matters is good color grading. I want to use high definition range here. Maybe what I want to do is try and bumped the temperature up looks a little bit more moody , maybe not. See if we do a bit of a tent. More like that is what we were going for originally. So maybe a little list like that are so and Mrs may be do this. That's a lot brighter than what it waas to stop that Make sure it's kept our sittings, and that's quite a bright See now I think it looks not too bad. Let's look at what it looks like with the building. So let's go to our main camera rear. Enable a scrolling. Well, sir, go to our game manager and allow our mouse pointer and she spread across and place a building. So you see, it's quite well illuminated as well now. So I think this is looking pretty decent. You can go in a justice anywhere you like. The only thing that I want to do as well now on this is going to mess up. Our camera controller is, too. Let's move on camera into a bitter space in our scene. So I'm going to. Maybe just told our camera ever so slightly I want to do is maybe bring this into one a into a 60 degree and a 1 80 degree notation, and then they should see what this does. It's not going to work now because we've missed with the orientation of our camera. I'm not exactly sure where it's looking at now. So let's see where we all that 000? Let's go ahead and just quickly create a three D object and call it Oh, plain and delicious. Make this 60 by Sethi, 60. We can more. Let's see where we are looking and lists changed the default material of this with the click. Actually, I think it's a several IQ. So the main camera. Okay, just maybe add a texture to this so that we could see what this plane looks like. So listen, stray that onto there and then look at our main camera. So it's not really looking in the direction that I was hoping. So I want to Ruth this back onto river up and really decide. Andi, then a small looking at our actual seems delicious. Rotate this. It's not quite looking where we wanted to get it in there. And then we want to move it across like so. And the other thing is, we maybe want to just change the decks of field of this A little bit, you should see. Is that 0.3? I think that maybe is fine. You just need to my resume this camera in So what I'll do is I'll actually use the line to view function that we have. I'm going to go down to where our terrain would have been. So and I want a bit more of a top view, if a sort of the liner to the way we wanted Want to prepare more of a year like this, and I could some to go to game object and I can go to you move to view and lying with view like that. Certainly single and disabled this and hit play. Read more of, ah, view like that now, but obviously are scrolling when we're correctly, so it's just very quickly try and fix it. It's going to our camera controller, and maybe what we just want to do is change this to forward and this one too forward and hit save and let's see if that actually fixes the issue. Sir, play is that Let's sort of working in the right way. We want to zoom in a little further than that. That's not really good enough, so let's just enable this plane no main camera right in there, one to lower its ever so slightly and get it going forward of it and down and forward, maybe a bit too Ford. See if you can actually see it. Otherwise, what we'll do is we'll zoom in here like so, and that's more or less. Let's look at the core down and then we can go and ally in this came object left of you and align with views like that. And it's just try this again now at the plane and play this left and rights. Let's play around with the camera while in the scene it's festival justice able this camera controller of year it play. Let's see what the issue. If we moved it town words so would have been because Value Z excess. Let's move the Why access down or up? OK, so we would want to be more or less starting at about, let's say 31. 30 point to about there and in the Z excess we want to start at about. You're on the X over here, so now we connect a grand place, our camera so you can right click over here and you can say couple components and we can stop this on Jermaine camera. My click and you convince a paste component values, and that should place our camera for us. So this play that and I could see we've got this top down view off our scene. That's another way of how you could place your camera, and it's going to enable this controller to make sure everything is still working. So I think this is not inverted scrolling in the wrong direction to begin to fix that quick in the script. So we'll just invert this video and we'll convert this ready over here so you can see we've played around with the camera quite a bit just to get it right. So it all depends on your view, and you need to play around with it yourself as well. But that's how you can play around and you see we can astral across, and I think maybe we are too zoomed in. We're going to just move back. This is likely and let's hit play. I think that looks a little bit better now. We're also not completely aligned correctly, So what I want to do is just make sure that this 1 80 and I want to make sure that this is 90 degrees. You see what that looks like. A lot of trial in area, I said, And live dance that looks traits like that again. What for gang to do. So going to you just disable this camera controller and hit play over here. Okay, then what I want to do is I just want to play with this rotations Want to irritate X likely upward like this. So we've got a bit more of Ah, swell A view, often to the distant rather than a complete top down view. You'll see if we move this down to say 90 degrees has full top down view. 60 is slightly off Centre 45 is maybe too much. Someone look at about 60 degrees on the X something that's a good place for it to be. It's unable to camera controller and see how well this actually works. Good habits. You here and your interest. 60. And let run this, uh, need to enable this. Yes, that's right, Wolf. Because I thought the mouse is very far away. Isis, roll up and down. That's the works lift. Right? Okay, So that allows us to do that scrolling, I think maybe the other thing. Why this is looking a little bit strange now is that maybe this ambient occlusion is maybe a little too much. So I'm going to remove this thickness modifier, make this scalable, ambient occlusion, and then I'm going to just keep the radius. Maria 0.25 Let's see other looks. It's still very intense. So I'm going to go and disable this camera again with this camera controller. You see what this looks like? It's just carry on with treating post processing a bit, not completely comfortable. I think this is two metre white and are seen ever here. Let's see if we drop this intensity. What does it actually, hopeless game brings in mawr darkness for us. A lot of this is playing around with these values, and it's getting an idea of what they actually do and how they change your scene. But MBI in seclusion is basically there to create some detail. So let's just, uh, touching of these. So maybe it is color grading that is creating this mm things effect in this may be because of too much exposure. Maybe. Let's just try. This is here and there. Actually, the sable is completely tender explosion. Valid trillion, maybe one reserve point size looks Case. I think it's just these white spots are quite bothering me. It's definitely not the vignette that's doing it. They still exist when you've got the pros process volume in place, so it could be that thes. The lighting is the issue here. Let's make this one and see if that reduces it. It's like this. Maybe three. See how that looks. Let's go back down to one. Go back into the post processing aumento occlusion on again. Let's go back to your multi scale volumetric. So this way you can actually play around with these things. Quite live bloom. I want to maybe bring up a little bit into Ding. Also allow official to be is open to maybe run fast mode. That makes the difference already reaction need to enable that otherwise we won't be seeing any of us. I wanted to have a bit more of a classic, so I think this might be in my Cischke smoove color grading quickly. It's got a bit of them musty sort of Farsi effect. If you like that, that can work at the color grading again to bring in temperature again looks, but more like that blew me. Just Teoh. See how some of these other effects look neutral's not bad custom. You need to play around with this curve. None, right? I definitely want to use cases here. Mess for sure. Bring us up to one. So maybe the other thing want to do is maybe just change the color of our light a little, but maybe we want to go to the greener side. So we'll see. It makes it a bit more green. We'll see. Maybe whites. You could do like a really creepy horror type game like this. Little get carried away here. Just focus on what we trying to achieve. You all right? I think that's fine. For now, we can still play around with these values, and so can you can go away and go and modify them as you need to. So guys I think of covered way too much in the slick Chur. It's been about post processing. It's been about lighting. It's been about changing our camera around and turning things on and off and also testing things. So thanks for watching this lecturer guys. So I'll see you in the next lecture 23. Fixing up some visuals in our game: Hey, guys, welcome to this lecture where we're just going to do a little bit more clean up again off our post processing. And I'm just going to show you what the actual issue was with this map and when we do press play and we had this a white spots all over the place. So the reason for this is I found that in our materials it was this smoothness effect going on. So you'll see if you go and remove this. It's just it player. So you can see what it's actually doing. And we dragged this down. It actually removes that. And the smoothness is creating reflections from a light source. So just make sure also to go into your materials if you want to have the exact same effect that I do and just make sure that all the smoothness is said Teoh zero and the metallic as well. So that's going to just take the this moving this out of it. So I'm going to do this with the rock material as well. And, uh, they should see that looks a lot more cartoony, like the original project. So the other thing I want to do Just to make this look a little bitter is to bring our sky bear skybox back into the scene. There were going to go over to window rendering lighting settings, and I'm just going to click on this little circle here and select our sky box. So this is but our engines on the original a city builder game had a more of a blue tint in the background, but you can grade and changes to what if you like. I do find that this makes it a lot brighter, if that's what you're looking for, but we could do just go and modify that as well. So if we go back into skybox and actually it's a modified this, while this is playing so that we can get a better idea of the effect, so it's got a little bit of ah yes, maybe go for a doctor effects and bring down the atmosphere like so that just gives it a bit of an orange 20 in the background, which just make sure your game look a little bit nicer. And then the other thing we want to just look at again is our post processing and make sure that our bloom isn't over intense. This mike 0.6 and this just have to stay a few more tweaks. So it's more on the green side so we can bring in the color again, which is find the ambient occlusion. We change that. Lets bring it back into multi scale volumetric and just give it that little bit of intensity. Maybe we can grab to one that's got a lot of shatter them. I'm going to actually bring this down. I don't want too much of that shadow effect, so I think this looks a lot better now. And this is a lot closer to the original City builder game like that we had. But obviously you have not seen a lot of different ways of changing this or go ahead and modify it to the way you want it. The look of this is not really going to affect how this game plays, and this course is mainly focused more on getting a playable game with object placement it a try to teach you how to just go from nothing. Teoh, somewhat city builder type mechanic, so that you can create your and city builder game So this is all nice effects. And this is just a bit of an introduction off. How all of this works. Guys things, watching this lecture in the next one, we going to be looking at creating the mini map using camera projections. So I hope you are excited about that one, because that will really bring the whole thing together. And it will start looking like a city builder game. So things looked watching. See you in the next lecture. 24. Creating the mini map: Hey, guys, welcome to this lecture. We're going to be adding a mini map to our game. So how are we going to do this? Is we're going to be projecting a render texture from a secondary camera onto another texture which will hold in display in a euro element. So this sounds very complicated right now, but let's go through these steps. The very first thing we want to do here is we just want to start off with a U elements so that we can place our many map on our actual game project. So here in the Iraqi, we're going to right Click, gonna create a U I. Element, and we're going to basically go down to canvas. And let's just call this action panel because later we will be adding our buildings in here is well and we will want to be just want to structure this correctly from beginning. So here we're going to just make sure it's screen space overlay and the US scale MEREDITH skill with screen size that it's just going to help us. We're scaling this canvas as a screen size increases or decreases, and I will help you if you have to put this to my ball or whatever you need to do. So after that, we just to show you how this actually works, I'm going to right click and just create a button and you'll see that say, in the middle. So the easiest way to modify your you I, if you are not in this mode, is to click on this two D View says, You can see if you're not into Devia, it's gonna be very difficult to edit this. I always use to the view when working with you are elements. So let's just run this so I could show you what it looks like. All right, Now you see you've got a batter. Nate, let's stop. Let's get rid of the button and let's start adding the rest of Are you I So what we want to add in here is I want to add another canvas, so I'm going to right click You are, and I'm gonna go to canvas, and I'm going to just rename this to many map and then I want to right click and create a you element, and it is a panel. So this is what we're going to be projecting our image onto, So I'm going to rename this to many image and then much will do. Is this script ever here? We're going to get rid of it so removed component, and we're gonna add a component called whole image. So this to show you how this actually works now. So now you're going to see It's just basically going to be this white screen all over our game. So I'm going to go into some of our graphics year. I'm going to go into textures and I'm going to just click on this mini map image, and I'm going to assign that this random textures and I can actually see that it's not textured this panel with this texture not to get our many map working. We just want to start by re sizing this entire thing. So let's select both of these and see if we can resize this down to more or less where we want to A minimum to be. It's about there, and this may be moving up a bit that makes a little bit more sense, more hovering over the screen than hitting the boundaries. So then here, in mini map image. I'm just going to get rid of this and set it to nine. For now, while we go and sit up everything else, it's none. And now, to get our image working, what we need to do is in the main camera. We need to create another camera. So I'm going to right click, and I'm regard to Camera Marine and this too many map camera. So here you will see that there is a target texture so we can take whatever this camera sees and projected onto this texture over here. So to create this texture, I'm going to go every into assets, and I'm just going to create a new folder and I'm gonna call it predictions. And inside that folder, I'm gonna right click And, um, I got to create and take on render texture, and I'm the coldest, many Matt. So this is some settings over here. I'm just going to leave everything as default for now. And then what we want to do is in our minimum camera. We want to sign this texture ever here. So now the what the camera sees will be projected onto this texture and then in are you. I element they want to show this texture. So now you see, it's just this orange. Let's play this to see what it actually looks like. No, and I can see that it's not gonna projection off this view because it is now attached to our main camera. Now what we can do here is we just need to re enable our camera controller, and you will see that this actually projects as we move around to see that creating a projection off our camera view ever here. So what we want to do just to make this a little bit more of a top down view that's going to play mode and actually, it's justice able this scrolling for now, Okay? And then we can go and play around with this camera. Well, it's rotated on the X. If you can get it to more of a top down view. Let's make this 45 degrees too much. Remember, because this is now a child of the main camera is relative to the camera, me one to maybe let it zoom out of it in its actually zooming out, because generally these many maps at a lot larger view off the scenes that can make, maybe make it 50 or so. You've got a different view now. Mawr in detail off the entire map. Maybe bring this down because it does look like it's skid off a little bit. Let's maybe bringing to about there. You can adjust this obviously, as you wish. That looks a little bit better now, so let's just copy this details. So we're going to right click your copy components and go out of here and regained to paste the component values back in. So now when we run this, we've got this top down view of our many Met and just what I want to do just to make this more care, because now, blending in with our background used to just take this the map over here. Let's see if we can resize it up. Actually, that's not what we want to you. It's maybe give it a new background. So let's create another panel under this, and then we can just resize this up slightly, like so and in our background color, we can change their to black. Give this a bit of a black outline, and it's just make sure that this is not displaying behind our other you element. So get out of two D View and Smith is back like this. See if that's actually for the back that's actually in the wrong direction. So what one gets moving forward year on with still black. Okay, Going to need some tweaking here, it seems several get, uh, the layers that were on says sometimes can cause issues. Smooth is up to layer like that. See, that makes any difference. And I bring that forward plus the Z Ever since that post processing layer, let's see that. Okay, maybe reorder this and every guy that's basically now fixed that, and we cannot. Well, once we've been able describing again, we can then play around. So this is something else you need. Teoh understand about unity sometimes is the rendering order in these object trees to make sure that they are rendered correctly. It can also then be the layers that these atoms or these objects on, as well as their Zeke ordinates in space, which could affect it either being on top or behind like this. So, guys, that's basically how are you creating many map? You can go ahead and adjust Jewel's anyway. You like, make it the way you want it. So that's the end of this lecture. And thanks for watching see in the next one. 25. Creating our Game UI: Hey, guys, welcome to this lecture. So in this lecture we're going to be looking at creating, are you I elements so that we can place our buildings in the next couple of lectures and actually have a few more buildings which we can place. So this is where we left off last time. It may be created. This mini map you, I element. So let's go ahead and just create our panel here so that we can start having some options for buildings, etcetera. So you'll see in your ah Tao nerd fourth es, it's they will be a folder called you I In There. And it's going to contain these various images along with these buttons which I have created. So it's a start off. Let's just create some your elements are Make sure you on two d murder and in under the action Penhall, right, click and create you I and then you're going to you select canvas. So we're gonna rename this to just say building like that. And then under that, we're going to create a panel so right click you I and then create a panel. Andre. Nameless, too building. Do I? You can resize that down, sir. I'm going, Teoh, actually, just bring this entire thing done like so And in the panel itself, let's just controls it just to undo all of this and select both at the same time and resize it, so keep it consistent, and I'm gonna bring it down to about there. So you're going to see it's gonna look like this at the moment. Okay, so you've got a few options. Your first of all, what we're going to just make sure of is that all Are you are elements on the u I. Layer because we did play around with this in the previous lecture. So just make sure that all under you, I layer like that, go out of two D view and then we want to make sure country have actually moved this back so that it can be other displayed off. What action is to be displayed at the back of all of these elements. And then also just the ordering here. Make scenes as well to change that. So you can see it's not displaying behind our mini map. So now a few things we can do here one we could make this very simple. We could make this black background with some transparency, and you can modify that with this Alpha Channel ever here and then it could look like this . But what I've done is I've created an image Richard can use. I've got this. You I dialogue just to show you how you can actually bring images into your scene rather than seeing using flat colors for this. So clicking on building you are here. I'm going to drag in this. You I dialogue into the source image, and I'm going to make the Alpha Channel off fully colored. And we're going to just make the color white. Now, when you hit play, you're going to see that we've now got our actual graphic which were using for this. So let's not go ahead and bring in our buttons. So our buttons are basically these two buildings so that we can select which one we want to use. So very simply, we're going to right click on here. We're going to go ahead and create a you element, and it's going to be a battle. So for this button, we want to just remove this text object, and this rename this to Skyscraper Beauty in Rain Today might like that. And then let's go ahead and create another button. And we're going Teoh again. Get rid of the text and we're going to rename it power station station bto. All right, so the next thing you're going to do now is we need to sign them some graphics. So I'm gonna click on the skyscraper one and you'll see the source image. I'm going to drag this in there and then for our power station. I'm going to drag this in there now. They're going to be overlapping at this point. See, that will just sitting here. So let's go into two D view so that we can position them Stop with the skyscraper here. I'm going to go over to the move to and I'm gonna move it left, and we want to now resize it as well. So just go ahead and resize it to what size you want. And then again, with the power station building, we're going to me that across an and also resize it. So now when we hit play, you'll see that we've got these buttons and click on them. So I will use the Easter, then select the building we want to place in our scene. So that's it for this portion off the you I The next you are elements we want to create is we want to create the A statistics bar over here. So to do that to be going to go ahead and create another canvas. I'm just going Teoh, bring clothes. Ease up in on our action panel re only have this portion here. So do you want to do is close this up and we want to go and create a whole new canvas. So you I and then canvas over here and we'll just rename this steps, you lie, and then we're going to want to create a panel, so that's gonna full screen. So let's just select both Is this direct tool over here and then we're going to just resize them. The other thing is just need to make sure we've got Elice options done correctly. Said one scale the screen. See why this is not scaling correctly. This is move this out of the way first. Okay, so we're gonna bring our panel down. It looks like a canvas is now not wanting to resize for some reason, you bring a panel down and move it into position. Have are you I Every year somewhere, I bring that, um, flounder is going to keep this background so that you can actually see what we are doing. Then what we want to do is we want to go ahead and just create some can actually use the buttons for this, whatever we like, because batons will actually have text right click on the panel and right. Good to you, I and go to button to see if this is gonna work nicely or not. And then this Just go back to you. I ever here and lets you select this money bar and see what that looks like. Drag that in there and this is go and focus on it by double clicking. It's no little. Have a look. If we change this button text, you dropped out of here and go to text and we just the dollar sign in here and then we align it to the left. Does that work could then also just moved the text so it can be over there. This doesn't look too bad. We just want to make sure that this is displaying correctly service. Maybe just resize this down a little bit like this and then move it over on our panel. Is there a printer being white like this? We will change that in a second. Which is me to make sure that our you are element is a good size. And this might just make it a little bigger for that. Just going to the button and then resize old thing that I were. And then we're going to do the exact same thing for the other two. So I'm going to press control D on this control de again. So we're just going to position these some river down and then for this button, the same thing, and in the only thing we're gonna do years change the text and the image uses. So for this button, let's change it to the electricity image. And for this button, there's changes to the water bar image. So here, I'm just going to type in the units that were going to be using. So for this, it's not gonna be dollars. Things be liters. You can make it gallons, depending on your country, and then this is going to be killed. What hours for power. So just for the ticks there just to make it look a little bit better, it's bold, it all of these. And then this is Look at what this looks like. I'm actually think these could be a little larger, so delicious selectable of them and then resize them all. They want to go like so and position them on our panel. And then let's head over to a penalty again and give its transparent background like so and let it run and see what this looks like. Now we've got Are you I ever there and we've got our various buttons. This is a Democrat. It's make it bigger than what it is. Scale this up quite a bit like that. Maybe ever. It's a play. Okay, so that looks a little better. Maybe just go down a little bit. It's Maria, but too large like that. And then we can bring it closer to the top left corner by moving it. They were basically got a scene. Now, which looks like a city builder game. We've got a stats. You are ever here. We've got some buildings weaken, select a mini map and we've good. Are terrain etcetera as well. I could still play some buildings. It's just in the next. Few lectures were going to be looking at a particle system for when replace the buildings, to give a bit of an added effect placing the building. And also we're going to look at how we can select different buildings and place them on our terrain. It's got tested for this lecture. Thanks for watching see in the next one. 26. Particle System Effects: Hey, guys, Welcome, Teoh this particle system lecture where we're going to be creating a particle system for when we place our building. So what we going to be doing is we're going to be applying a texture and then we're going to be emitting particles in a particle system and playing that when we place our building. So what you'll see is in the graphics folder. When you've downloaded all the assets, you will go into textures and you will see this particle texture. So to prepare this texture for particle system, we're going to have to turn on. The Alfa is transparency. So and then we need to hit apply. So you'll see that this removes the background from our image just to give you a bit of ah , background on why or how this actually has been created. The one The reason for this particle is that we've got some type of effect which is being emitted, and also the way I created this particle is just simply doing to brush strokes. In further shop, you can use gimp. You can use any editing program which has a breast strike or just like a pencil tool and you can draw whatever particle you want for for your game. So that's the first step is to just get the texture is sorted out in. The next thing we want to do is we want to create a particle material, so let's go back up to s. It's graphics and materials, rightly care, create and goods material, and it's called us particle. Now what we want to do is want to bring our texture into the albedo slot. So what we'll do is we'll just click on that little circle, they and select our particle. No, you'll see it's filling our entire sphere down here. But what we want is to do a cut out that only cr particle portion that we painted on our picture. They will see that the wrist of this is transparent. So the next thing we need to do now is to actually sit up our particle system to do that. You see, I've already created one here, but let's go and create a new one from scratch so you can go to just click in Hiraki, go to game object 30 effects and click on particle system. So what we're going to do here is we're just going to go ahead into our scene and just make sure we're focused on this by double clicking. What we want to do as well is, is there a these values out so that a particle system will always spawn at the origin in our world. So what you'll see now is that it's the just admitting a whole bunch of random particles which are white at the moment. So before we actually apply our material, we just want to make a few adjustments here. So the first thing we want to do is be want to make this particle that more like a burst, So to do there to be going to have Teoh decrease the duration it's playing. So make the syrup when full, so you won't see any effect now because we are amending so many particles at the same time , you can barely see the change, but I've updated this, actually what it's put this back to 57 You can actually see that this will make a difference. And also the other reason is that it's looping, so you can't really see what difference it makes it free. Unlu up this see that it has a slight effect. But if we do this on 0.4, you will see that it's going to clip the effect quite quickly. So I'm gonna put this back onto looping so that we can just see what this looks like. They're out and hit play. So the next thing we want to do year is we want to decrease the lifetime of our particles. And what that will do is if you see here, there's a start lifetime start. Lifetime is just how long a particle will live in our seen before it's destroyed. So we're going to changes to 0.2 because we want to have, like, a burst. As you can see this, this short burst off particles and then they get destroyed. So it's maybe just zoom in a little further here so we can see this political system more detail. Maybe for now, licious. Move this over here so we can see it. Don't have that pre processing icon day, so short bursts, as you can see. Next thing we want to do is we want to just modify and the speed at which it is emitting. So we're gonna change this. Start speed to 20 so you'll see it's moving a lot faster now. The next thing we want to look at is Thean mission. You want to basically emit more particles fast there, so we'll just put this to 20 in. See, there are a few more particles as well. Now the thing just to make sure of is that your playback speed is on to the default is usually one. So just changes over to two, and then you'll have something similar to this. Next thing you want to look at is the shape at which we're emitting. So when you click on that, you can see that it draws this Hoff cone with a bunch of lines, and it'll emits from this portion or the shape out into a world. So we're going to change this to a doughnut, so we'll see. It's now going more outwards, and from here we're going to just limit the size of our donut by changing the radius zero up 1 to 0.1. Next thing we want to look at is actually a rendering our particle. So as we can see, you only have this dot particle at the moment change that. We're gonna go over to the renderers and we're going to drop our particle material that we created in there, and you can see that it is now basically being spawned. The next thing we want to also now look at is the particle size it's splitter under. These values were gonna start off the 0.2 and unlimited to Europe. When two. This is starting to know. Look a little bit more like what we had in our original video in this for this course. So this will play on awake. And Michelle, you were that actually comes from. So I just find that portion. You think it's maybe in the renderers? Let's see, There is an event, not shape. Must be in here somewhere. Here we go. Play on awake. So this is checked A soon as a particle system respond, It will didn't just play, and it will play this effect. So let's there bring this into one of our building so that you can see what it looks like. First thing when it is, just take a looping off. Otherwise, this is gonna go on forever on 20 out our political system again, and I want to just go over to assets here and pre Febreze and I want to drag this particle system in here so that we can use it on our building. So let's open this power station, go to open prefab, and then we're going to drag this under Palace Station. This is play this. See what looks like? Um, I think it looks okay. Let's try this in game. Let's play and it's just click America's. He's got that effect. It's not smell bad. I think the particles maybe just a little bit too big. So what we can do is we can just click over here, go into our actual particle system, and then we can go and just change the scale of this. I'm going to maybe make this 0.1 and 11 and then let's see what this looks like. A za a short burst, and it plays our political system so that will signify that. Respond a building, guys, that's basically the end off this political system lecture. It's that simple to add a particle system and a thick to your buildings to re going to be adding this effect to allow buildings fang forward. But the guy you can go and customize your particle any way you want. You can go and edit the image. If you don't want to do that, you can just use the particle life created in your no project. So, guys, Internet. Thank you for watching this lecture. I'll see you in the next one. 27. Adding more buildings: Hey, guys, welcome to this lecture. Let's now start getting set up to allow for our other buildings to be placed. So to do that, we need to basically go and create a building pool object. So to do that, we're going to go in tow Iraqi, and we're going to right click and create an into game object. And I'm going to rename this building pool. So all the different buildings that we want to spawn, we are going to be placing as a child of this game object, and then we're going to find it via script, and instead Enshi ate them as needed. So the next thing we need to do you here just to get the set up is to go over to our graphics folder and into our pre fabs. Or actually, it's in S. It's pre fabs. And then what we'll do is we'll go over to the skyscraper. So we've already said our palace station Ah, in earlier lectures, but now the skyscraper building and it's p set up as well. So what we're gonna do is being a click on the skyscraper, and we're gonna go open, prefab and first of all, we just going to get rid of this point light because we don't need it. And then you'll see it's got this cube object which has this mish renderers which we need to use if we want to change the color off building while it is being placed. So that is definitely needed. We need to add a cinematic for a rigid body to its Ah, it's exactly the same way we had it for the power station and we needed freeze position expects Why rotation and Z NZ positions then. The other thing is we want to add a collider because we wanted to check if a building can be placed in a certain position and we don't want to allow a player to be able to place a building on top of another buildings. So we're going to just add this so that we can detect collisions later on and in. The other thing is we need Teoh add in ah particle system, which we created in the previous lecture, just so that when the spoons it actually has our particle on it so I can see that works and that's that. Full the skyscraper. Now what we need to do on our building pool. We need to just drag and drop are two buildings on top of that. So this will allow us not to go and excess thes via script and then spawned them in our world. So what we gonna do now is just start off by modifying our mouse pointer script. We're going to keep everything in there just to keep it simple. You can go ahead and actually split this off into a different class and deal with the spawning and everything separately. But for the purposes off this course, we're going to keep it extremely simple and a licious guy over to visual studio and start editing that script. So some of the first things we want to do here is we want to start tracking the currents born object and will certainly in 12 look at a way of moving that around, are seen without actually placing the object. So festival read me to just go ahead and creates a public game object, and we're going to be calling that current spoon object. Then here, in our logic of our mouse buttons, we want a way to actually remove that item or cancel it so that we don't allow the player to place its This is going to be the right click on our mouse. So here we want to actually go ahead and delete the current object that we've got selected . So we're going to just call destroy selected building. That would be the building that we've selected via our menu. So if you could play over here, um, we're going to eventually wire this up to these two buttons, and that's going to affect the selected object that we've got selected. And let's just look at that little dream. Just destroy it if we click on the right mouse button and it will. Instead, she ate it. If we click on the left button at this point, it's going to be placing the object leading to change this little bit. For now, this is actually fine. Just to move it around are seen, and then we need an else object or else their statement to go and just check if we have a selected building, first of all, and if it's not know which means we actually have a selected building, then we can just simply move it around the scene without any mouse interaction. So if none of the buttons are being clicked and the mouse's was moving around, we can't move our object on a terrain or in Arsi. So to do that, we're going Teoh actually reuse this nearest point members here. So every snap to the grid and they had point again because our mouse is actually hitting the surface off our terrain, Then we simply just going to do the transform. So it's going to be. This exact piece occurred here as well, to reuse. And then the next thing is, we need a way of selecting our buildings, and that's going to lay to be used in Are you I, in order to go and select various buildings off the button, clicks. So here we're going to just create a public void, select building, so that will be our skyscraper. Let's my brother call it Select Sky Scraper, and we're going to have another method called they avoid select Power Station. These two are just going to have a little bit of logic to switch between the current spoon object and destroying it, depending on what state we are in on the mouse button. So these were both going to have similar logic. So I'm going to do the one and then I'm going to just copy and paste most of its current into this Miss it and just modify it. The first thing you want to do is we just want to make sure that the current spawn object is no. Which means we don't have occurrence bone object and that the current sport object doesn't have a name attached to it. Just just to basically make sure that we definitely don't have any object selected and just lift force named Skyscraper. Well, just check our game objects in a second to make sure that we actually have these with these names and then we just going todo a check. If selected building is not know, So we have a selective building seamlessly. Then we want to go and destroy that selected building because we are now going to select a skyscraper. If there's another selected building already, we want to get rid of it so that we can use the new building. Then we're going to just make the currents born object equal a game object. I'm gonna use the fine method to find our skyscraper and we're going to inst Enshi eight are current Sporn object and said it to our select the building. So that now gives our slot for our selected building the spawn object that we clicked So it will become the skyscraper. So this isn't me exactly the same thing here except now we're going to use power station in this position and power station over here Just started re select a power station and then we assign it to the selected building. So I just to keep this really basic. Now we're going Teoh just also add some other effects to this and it's going to be the selected building dot gift component and we're going to use the mish renderers and we want to go and fix the material and the color off the material. Unless it is to a green. This will be when we can place an object, always be green. It's not be the same here and save that off. So to get this working without actually using IR, you are at this point I'm just going to ran select skyscraper ever here Berries and I'm using the skyscraper is because I want to taste it out because we've just set it up. We know that the power station we can place the object on our terrain. It's a dresser wishes. Give it a guy with a select skyscraper. So let's go back to unity. It's just make sure that our buildings actually have the correct naming. So you're going to Palace Station, its policy station. If you can describe Scraper, it's skyscraper. So let's run this. Let's see if it works. Something is wrong. Isn't error over here saying that the whole reference exceptions are delicious? Have a look at that. And, um, it's look, Tim projects. Make sure what? Okay, that's obviously but wrong going to selected building. That's what we're moving around selected building over here and let's go ahead and gives us a guy. His plane. Actually, they want any errors. This time there's still some errors, so we're going to have a look at that because you could see we can least move our building around like this now, and it's got this reddish tint and place them. If we right click, you'll see, it'll disappear and we won't be able to go and add a building again until we click one of these. So, guys, let's just quickly look at this era before we in this lecture. So here it's complaining about the material of color. Okay, so as we saw previously, now it had a red tent and not a green tint. So something is wrong with this. Mishra interests of its trying to fix this. So I'm going to go into you, this skyscraper over here. And I think the issue is it's trying to get the measuring Durer from the skyscraper objects . Let's add that ever here and attached to the material, let's see if that resolves that. Okay, so that's actually taken that error away. And then there is still an issue with the color of this. I think what we need to do is we need to remove the mesh renderers from the cube and the Michigan lighter can stay. So if that makes a difference, that's actually removed it completely. So let's just undo that. I think what we are going to have to do is a refectory, er this skyscraper object completely. So what I'm going to do is I'm gonna rename this to Skyscraper. That going to the England. Just create a empty game object so I can read things around. Repeat this in ever Hear, See if we can somehow just get this to become the parent objects. So that's essentially what we want as wise, What will need to do is just go and create a completely new prefab from this. So to do that, I'm just going to go into the project over here, and I'm going to drag this portion of the skyscraper in, and then that's gonna become our new prefab. So then one of gonna do is I'm gonna delete less prefab and replace it with the new one. So get rid of this skyscraper here. I'm gonna get rid of this skyscraper, which is the Bracken one, and then I'm going. Teoh, open this prefab and I'm gonna rename it to Skyscraper. Hey, night And it gets renamed with particle system. It's got a cube, Scott, Our mission colliders has got all of that. This is Rita apologized it Let's see if it now as an effect. OK, so there you go. So now the material is green as intended with the script, and basically comm place this right clicked delete. And the other thing we now need to do is to reset these colors in the event that replaced the buildings. So anyway, guys that has basically just being the set up to you get our skyscraper working as well in the next few lectures will start sorting out some of these issues and getting Are you live working as well? Thanks for watching guys see in the next lecture. 28. Connecting our UI so we can select buildings: Hi, guys. Welcome to this lecture. So this is just going to be a very short lecture just to get our building buttons on our little action panel down here tired up to actual script so that we can select a building and actually start placing them as we like. So to do that, what we're going to do is we need to first of all, attach our script. So just to keep things simple again for this course, we're going to use the game manager object. Usually what you would do is separate this off into a you I'm manager object, which you can obviously go and dio quite easily yourself. However, just to keep the simple and actually focus on the project itself in the game itself, I'm going to use the game manager for this. So the first thing you want to do is be want to click on our action panel and we want to go to the drop down and get to our skyscraper button. First of all, when under writer inside, you will see this unclip option here, click on the plus and in drag your gay manager into this object slot. So what that's going to do is because we've got our mouse pointer script attached to this. We can now actually go and sign a function from the Mouse Pointer script so we can go down to Mouse Pointer and we can go to select Skyscraper and for a power station button. We're going to do exactly the same thing, going to drag in our game manager and we're going to select and the mouse pointer and and go to select power station. So let's play this evil works. I'm almost sure we're going to see a bag somewhere. So first of all, we don't want to start with the selected building, so we need to go fix that. But let's try under select power Station and you see this bouncing effect. So let's first of all, start with just getting rid of that initial building that selected. So let's go ever into visual studio, and we need Teoh not call this method, which we did previously, so just give it a that go back into unity later. Look, if it's still doing nets, okay, so there's no building selected. Let's elect the building, place it screen. Another issue is that it's doing this bouncing effect. So the reason for that is we've got a collider on all of our buildings and there are not sit too triggers. So in order to fix that scale here into a building pool, let's click on this error to open the prefab. So in our palace station, we want to make sure we said our mission collider to his trigger. Go back when to take out skyscraper and do you the exact same thing and just make sure it's the trigger. Let it run again and see if it's fixed the issue. I'll select the building now you ecstasy that it is falling through the floor, which we don't want, So to fix that, what we can do is we can just get rid of all these masses on our all stations snow, this rigid body to see. Do we want to use gravity? Let's say no and let's make the mess zero. So now be actually going to spawn this closer charred terrain rather than using the physics engine. It's a delicious moved back to the power station as well, and here we don't want to mess zero, and the other thing we want to make sure of is one to use Kinnah Matic, so that's gonna make sure that it stays in place so delicious. Go into a skyscraper, make sure you use it's can cinematic and get rid of gravity. So let's play this. See if it still has its own effect. Very good place are building. I will explain. Change buildings still lead to building. Try another building. It's not delete that. Let's try another buildings. As you can see, we can now change our buildings as needed now also, the thing is, you can see that some or the original color, some agreeing. So we'll fix that in the next few lectures. But I just wanted to show you how you can now get your you I going and start placing different buildings on your terrain and in your C guys. That's the end of this lecturer. Thanks for watching. See in the next one 29. Fixing our building colors: Hey, guys, welcome to this lecture. So in the previous lecture, we discussed that we would fix some of the issues in our scene. So one of the issues we have is when we hit play over here is that when we do select this building and replace it, it stays green, and it doesn't actually use its original material. The other issue that you'll see is that when we try and switch over to this building now it's going to fail and let me show you why that is. So when we start our seen initially, just watch what happens in this part of the building pulled. You'll see this power station disappear. So this is going back over to our map here, and then when I place it, you'll see it's still working. So in our right click, it actually deletes it from a bowling pool. So when we click here, we can't use it again. So we need to implement some checks and balances to make sure that we don't try to instead shade an object that doesn't exist. And we should also prevent that object from being deleted from our bowling pool. So the very first thing we're gonna do is just sort out this color issue and also just put in some conditions to make sure we can't actually select a building that doesn't exist. So I'm gonna get everything visual studio, and the first thing we're going to do here is in this portion off our code, we just going to do a check, which is going to be an if statement and we're going to check that are selected. Building is not equal to know. And if it doesn't equal to know, then we can then actually go and instead shit this temp objected place in our scene. So the next thing we want to do here is we need to change the color. So we've changed to green down here. But remember, this selected building is our building that hovers when we are actually trying to place our bolding. So wouldn't we bring this card up here? We actually want to apply this to our temp object, which is the building that just has been placed after the click event. And we want to sit that material to what? So that it will receive its default material. So let's hit into unity and see if that works. So I'm gonna click on this building immediately and click. So you see, it's actually taking on. It's a riddle original material and textures, and we can remove it. And now you'll still see this issue here. So if we can get project is still going, Teoh, error out And reason for that is, is this power station selected building over here? So you have to click on this little circle and go to none. The reason this is causing issues is because when we actually start with sitting up our inst enshi ation, we do a destroyer of our building. And that's basically removing the original building from the scene, which we don't want to do. So just make their change in that should fix jewel issue in your project. There's click on this building to place quite a few of want right click can take this building, place it and you see all the colors work, guys, that, sir, the end of this lecture that should get your game fixed up. So the last part of this actual set of lectures and this course is going to be creating the economy so that we have some dollar values as well as the kilowatt hours and leaders off our water stations, etcetera. And then we can actually finish it off so that you've got this entire game syrup and you can then go and extend it and add more buildings for yourself and whatever else you'd like to you add to this project. Thanks for watching guys see in the next lecture. 30. Setting up our economy and the singleton pattern: Hey, guys, welcome to this lecture. So in this lecture, we're going to start implementing our world economy for our game. So we're going to keep it very basic for these lectures, of course. And you can obviously extend yours anywhere you like and add additional properties and rules real actual game. But I'm going to show you how Teoh just bring in these three basic elements and how we can have our buildings affect our world economy. So the very first thing we want to do here is we want to just go and create a building. Script says building script is going to be attached to all of our different buildings and they're going to have a general set of properties and rules which will be able to make changes to our world economy as long as they are in our scene. So what we're going to do here to achieve this is we need to go over to s it's and scripts and right click and create a new C sharp script called Building. Once again, we're going to just open this up in visual studio. So here we going to get rid of all of these methods, and we're just going to declare three variables and it's a public into water. And I'm just going to copy this twice on one is going to be electricity and another is going to be money saved their off and let's go back into unity. So here in our palace station, we're going to click in this error to go into our prefab, and we're going to attach the building script. I just dragged it in there to know you'll see good these three values certain power station . So I'm going to allow it to prettiest 1000 electricity, use 100 water and produce 100 money for us. When I got back and regain Tuesday in Have a Skyscraper, we're going to do something similar, and let's bring ah, building script in again. So this is going to be a little bit strange because skyscrapers obviously done prettiest water. But let's pretend this is a water plant which is going to produce some water for us. You can obviously tweak this anywhere you like. This is just to balance the economy full this lectures and this course so once you have gone through all of this, you should be able to add your own buildings and also add your own properties so that you can manage your economy. So water. I'm going to say it produces 100 going Teoh take away 100 electricity and it's going to cost us 100 money as well. So that's sit up these two buildings to have some values which they comply to our economy. So here we've got that, and here we've got that. So for now, this building script is going to stay quite simple. Real add some additional methods later on to be able to affect our economy using the script . But for now, we're just going to keep it as thes three properties. So the next thing we need to discuss is we need to introduce a economy manager. And to do this, we're going to right click and create see short script called Economy Manager. So our economy manager uses a computer science principle called the Singleton design Pattern. So what this essentially means is we will only be able to create one economy manager in our entire scene, and if one already is this, then are seen, what just continuously returned the same economy object. And in doing so, we're going to make our economy a manager global and accessible to all our scripts. So we could actually then manage our economy from this building script or the camera controller script. Not that we would. But if you wanted to do that, you could So to implement the Singleton design pattern, I'm just going to open up this economy manager, and then we just going to start off with a very basic Singleton. And then in the next lecture, we will look at how we can add onto this to actually build a really economy manager which, well, uh, keep record off our money, water and electricity in our world economy for our game. So to start off, we need Teoh. Just have a game manager reference. We're sorry, an economy manager reference. So we often use this for gay managers as well for keeping player state. But this full This lecture is going to be the economy manager, but do know that you can actually use this full game. Managers, audio managers, likes managers. Whatever you need. Teoh have globally available for your game and it need to use throughout. So let's just start off. So the first thing we want to do is we need to create a private aesthetic economy manager, and we're going to call it instance. And then what we're going to do is we're going to use a Seefeldt feature and that is, can instance, keyword so public static economy manager and we're going to I used the word instance, and then we need to create a get method so they get method will the last to actually get this instance. So to get that, we just need to make sure that our instance exists. So one. If it is no, we need Teoh one created. So we'll go ahead and just create a game object simply. And then we'll attach our economy manager recreate in your game object, and then we'll just pull this economy Manager says. Soon as we use this in our seen, it will actually then. Instead, she ate a game object and then bring the script into existence within our game so that we can access it globally. So this object so C is maybe a reserved words delicious making O. B. J mean what we need to do is use o B J and we need to add a component to it. And that's going to be our economy manager. And then finally, what we need to do is return our instance that we just created then the other thing is we just need to make sure that when this script is inst enshi ated and it wakes up that it sits it toothy, correct instance of the objects of will use. Awake and instance will then become this so very simply, if it is no well created. If it's not know we will just return it. If it is no, we created and return it. So basically that will make our economy manager global. So to just give you a very quick overview of how this is probably going to work is let's create a basic property. Let's say, public into total water. This is a very quick example, and in our building we couldn't have a message. It's cool it avoid add water, and then we could go and say, economy manager. That instance dot total water and we could make this 100 for example, and that all were perfectly fine within our scene and in this way we can actually then manipulate our economy in our game. So thanks, guys. Watching This is the end of this lecture. I hope this has been useful. And let's try and finish up this economy in the next couple of lectures so that you can complete this course and go on to make your own changes and create your own game from this base project. Thanks. Watching guys see in the next one. 31. Expanding the economy manager script: Hey, guys, welcome to this lecture. Let's look at how we can expand our building close in this video and then start to just add some values to our economy manager. So very simply, what we want to do is we want to increase our economy and decrease our economy for these three different properties over time. Sorry, aunty, is an interval based ah, time which we're going to then go and up that our economy manager. So to get this started, what we'll do is we need to variables. One is a private start time which is going to be a float going to call that start time and then we need a public float interval which is going to be the interval that we're going to go and update our economy all. So from here, we need to declare a public avoid start method just so that we can get an initial start time value. So start time and we're going to sit there to zero initially and then we're going to use the fixed update may 3rd look to start adding to our economy at a fixed interval. So they start off. We need to take start time and we're going to add the time got fixed. Delta time to it. So this will allow the start time to count up to our interval. Andean ransom Tired. So here. We're going to just have an if statement. Wait. If this stop time, time is greater than our interval. We want to go and ads and stuff to our economy, and it's gonna be very simple now, Economy manager. That instance the total water and we're going to just add the amount of water that this building produces or takes away. So simply we're going Teoh, just do this one line for now, we're going to add some more to our economy manager straight after this ending, we're going to come and modify their script again and allow for electricity and money as well. Straight off there, this has been done. We want to Now go and sit our store tyrek to zero so that this timer can start from the beginning just to show you how this looks Delicious. Do a d bag stopped lug here and I'm going to call this total water on. I'm going. Teoh, the economy manager thought instance what total water here so that we can see it. So let's go and add this script. Well, it's already added to our buildings. We just need to go and modify its values. So go back into unity. Power station Still see, there's this new interval variable now which we can sit Just going to sit it to one and respectively, for the skyscraper I'm going to sit it to one. So that's it. Play. And what we want to do here is we want to have our consul open and you want to have a water selected while typed in here so we can filter are log. I lost the terrain. This just started in. Okay, so we can create some buildings. We'll see now that we've created some buildings, our economy is actually moving very false down here. A totals increasing pretty quickly for our water half when a slur down, we are electricity. Buildings were using waters. Let's just create a whole bunch of them this to bring the value down. I really try and slow it down here. So you see, now it's starting to into the negative because these buildings are consuming our water and arts completely into the negative. So that's how we can implement the water economy. Next we want to do is we want to bring in the electricity and we want to bring in the money . So back in our economy manager script, very simply, we just going to copy this out this and we're going to add electricity and we're going to add money. Not should be available in this building script. Very simply, we can just copy these again and modify it to cater for electricity. And you're going to use total electricity on Dhere reenters total money. And we're going to I had money over here going to get rid of the Steve by glogg because in the next electoral, we're going to start for King goes up to Are you I in our scene And we should then start to see these values update guys. That's basically it for getting the rest of our properties into our game. So thanks for watching. And I'll see you the next lecture. Yes,