Complete Business Communication Video Online Couse
Create a “water table” in your terrain. Dig down to create some water hazards. Paint mud under the water's surface. Preview water from the ground. === 00:00:00.000 --> 00:00:07.940 Hey hey, welcome back! So, we're going to be adding a water table, and you are in for a treat, 00:00:07.940 --> 00:00:13.750 because Unity 5 comes with beautiful water shaders built in, for free now! So, let's 00:00:13.750 --> 00:00:17.980 take a look! We're going to be using Unity 5's wonderful water prefab to create a water 00:00:17.980 --> 00:00:22.680 table in your terrain. Water table meaning a height in the terrain below 00:00:22.680 --> 00:00:27.240 which there is water, although you'll see that it's just a surface, but let's take 00:00:27.240 --> 00:00:31.949 a look. Dig down to create some water hazards, paint some mud under the water 00:00:31.949 --> 00:00:37.530 surface even, and previewing the water from the ground. So, let's dive 00:00:37.530 --> 00:00:42.469 into Unity and take a look at this. Under your Standard Assets under Environment, 00:00:42.469 --> 00:00:45.030 if you've imported the package, which I hope you have by now, you should 00:00:45.030 --> 00:00:50.330 have Water and Water Basic. Go for Water Water, that's the folder we're looking for. 00:00:50.330 --> 00:00:55.240 Standard Assets, Environment, Water, Water, and get a prefab, and we're going to go for 00:00:55.240 --> 00:01:00.340 WaterProDaytime, I think for now. They look very similar, by the way. If you drag 00:01:00.350 --> 00:01:05.330 that WaterProDaytime into the scene and double click it, you'll see that it's 00:01:05.330 --> 00:01:09.470 made a little circle, but it'll have made a circle in completely the wrong place. 00:01:09.470 --> 00:01:14.490 So, how high do we want this, for a start? Well, maybe 5 meters below our ground, 00:01:14.490 --> 00:01:19.610 so in my case that's at 45. So, that's looking a little bit better. Now, we need to move it 00:01:19.610 --> 00:01:23.680 into the middle of the terrain. So, remember you can click the Y arrow to 00:01:23.680 --> 00:01:27.439 look at the world from above, and then, move it roughly to the middle of your 00:01:27.439 --> 00:01:32.040 terrain. Look at your settings, remind yourself how big your terrain is, if 00:01:32.040 --> 00:01:40.290 necessary go to Terrain Settings 600 by 600. Ok. So, your water, and I'm just going to call 00:01:40.290 --> 00:01:48.090 it Water Table, should be at 300 by 45 by 300, in my case. And if we use 00:01:48.090 --> 00:01:51.960 the Transform Tool, we can confirm there that it is right in the middle of the 00:01:51.960 --> 00:01:57.960 terrain. Cool! So, the problem with it now is it's too small. So, what size does it need to be? 00:01:57.960 --> 00:02:02.939 Well, if we want it to go out to these corners over here then, it's 00:02:02.939 --> 00:02:10.500 going to need to have a radius of at least 300, so 300 by 300. 00:02:10.500 --> 00:02:15.420 I'm sorry, the Y direction doesn't matter, because it's just a flat circle, but 300 is going 00:02:15.420 --> 00:02:19.270 to get to the edge here but it's not going to get to the edges here. So, let's 00:02:19.270 --> 00:02:22.570 do a little calculation. How are we going to find out how big it needs to be to 00:02:22.570 --> 00:02:28.060 go to the edge? Well, it's going to be the square root of 2, isn't it. If you're any good at 00:02:28.060 --> 00:02:31.840 math, you'll know that it's going to be the square root of 2, which is 1.4 00:02:31.840 --> 00:02:42.540 times the 300. So, 425 will do. If we make a scale 425, in both directions, 00:02:42.540 --> 00:02:48.350 X and Z. Boom! Now, we have a water table that is just as big as our terrain. 00:02:48.350 --> 00:02:53.000 It just about touches the edges of the terrain, and wherever the terrain is lower 00:02:53.000 --> 00:02:56.930 than that, it will intercept the water table. So, let's go right down to the 00:02:56.930 --> 00:02:59.790 FPS Controller and have a quick look around, to start with. 00:02:59.790 --> 00:03:04.880 Now, if you've got any low-lying areas, like this big hole I'm heading over towards at breakneck speed 00:03:04.880 --> 00:03:10.700 over here, then, you're going to be in for a treat in a minute, because we're going to get Unity 5's wonderful 00:03:10.700 --> 00:03:19.240 water shader in our face. Look at that! And without even making any changes to the settings, it's already not looking half bad. 00:03:19.240 --> 00:03:24.640 Look at that! How cool is that? And you can look back at the Sun and have lots of fun. Now, we're going to 00:03:24.640 --> 00:03:28.880 improve the lighting, we're going to do all sorts of things, but I just wanted to show you how nice the 00:03:28.880 --> 00:03:35.160 water shader actually is in here. So, what that's done is it's put a water circle underneath the 00:03:35.170 --> 00:03:40.120 entire terrain, at a fixed height. Now, anywhere that you decide to go and drop 00:03:40.120 --> 00:03:44.230 the height of the terrain, now the water will appear, which is what I meant by a 00:03:44.230 --> 00:03:49.670 water table. So, you might want to create some water hazards, some water areas, where 00:03:49.670 --> 00:03:54.010 your zombies are going to attack you, and you don't want them to get across the 00:03:54.010 --> 00:04:01.370 water. So, as you drop the terrain, it will automatically now create water 00:04:01.370 --> 00:04:06.840 effectively. You're going to end up with some trees. So, remember you go to trees, and you hold 00:04:06.840 --> 00:04:13.190 down Shift and you just delete trees like that. Ok. And then, your FPS controller you may 00:04:13.190 --> 00:04:20.400 want to move across into say the middle. Where is the middle? 300 by 300. 00:04:20.400 --> 00:04:25.760 Let's see where we end up, probably in the water. Now, we're stuck underwater. Now, when 00:04:25.760 --> 00:04:31.460 you're underwater, it doesn't look like you're under water, because it's just not how the renderer 00:04:31.460 --> 00:04:35.310 works. And later on, we're going to put some colliders in, so that if we actually end 00:04:35.310 --> 00:04:39.990 up in the water we die, but in the meanwhile, I just want to show you how cool this looks, hey. Really coming 00:04:39.990 --> 00:04:46.320 together nicely. Now, there are some settings on your Water Table Prefab, let's look at it. It has a Water Plane Mesh, 00:04:46.320 --> 00:04:52.949 which is slightly different to a Normal Mesh. It has some materials here, it also has a 00:04:52.949 --> 00:04:57.880 Water Script, and you can choose whether it's Reflective, Refractive, or Simple. So, if you go reflective then, it only reflects off the surface. 00:05:01.840 --> 00:05:06.400 I kind of prefer that actually, and I'm probably going to leave mine reflective. 00:05:06.400 --> 00:05:11.540 But if you do want to better see under the surface, you can make refractive water, which is 00:05:11.550 --> 00:05:14.800 even more complicated. Now, that will reflect off the surface, but it will also 00:05:14.800 --> 00:05:19.370 show into the water. It's up to you which one of those two you use. I've never seen water quite 00:05:19.370 --> 00:05:24.440 this clear, so I think I'm going to just go with reflective. The other benefit of 00:05:24.440 --> 00:05:28.760 going with reflective is, if you're with refractive then, you have to start going 00:05:28.760 --> 00:05:32.660 in and painting under the water, otherwise it looks silly. So, if we go to 00:05:32.660 --> 00:05:37.100 this area here, it looks silly for there to be grass growing under the water. 00:05:37.100 --> 00:05:41.300 You could of course go to your terrain, your Paint Tool, get your muddy widget here. 00:05:41.300 --> 00:05:47.460 Maybe a smaller brush, and you could paint mud under the water surface, diligently in 00:05:47.470 --> 00:05:50.479 all of your ponds. Now, if you've got the patience for that, well then I commend you, 00:05:50.479 --> 00:05:57.679 and that would be great and it would look a lot better. But if you look in there, it's still ridiculously clear water 00:05:57.680 --> 00:06:02.780 isn't it? So, unless you've got a setting in the water for how clear the water is, I would suggest 00:06:02.780 --> 00:06:05.210 you just go Reflective water. It's entirely up to you. 00:06:05.210 --> 00:06:08.930 Alright and then, you can choose various other things, which I don't think 00:06:08.930 --> 00:06:12.250 we need to be messing around with now. You've also got some options under 00:06:12.250 --> 00:06:17.490 WaterProDaytime here, which we can look at, but It's best off if we can see the game view. 00:06:17.490 --> 00:06:26.020 So, I'm going to unmaximize on play, click play, go to the water's edge like so. Now, I can mess 00:06:26.030 --> 00:06:30.930 around with the Water Scale, and that changes the Wave Scale of the water. In fact, I recommend 00:06:30.930 --> 00:06:34.509 a slightly lower Wave Scale. So remember, if you make these changes in 00:06:34.509 --> 00:06:37.699 Play Mode it's going to forget them when you get out. And unfortunately, being a 00:06:37.699 --> 00:06:41.940 shader you can't copy these things, so you're just going to need to remember them. So you've 00:06:41.940 --> 00:06:46.320 got your reflection distortion here, which is changing how much it's distorting 00:06:46.320 --> 00:06:50.690 those trees. You see, if I put it down to 0, you see how kind of glassy it is. 00:06:50.690 --> 00:06:53.820 So, that's cool! Refraction Distortion is not going to make any difference here, because we've got a 00:06:53.820 --> 00:06:59.770 purely reflective shader. Alright so, that's the shader, which is the thing 00:06:59.770 --> 00:07:02.880 which is responsible for choosing how that surface of the water looks. 00:07:02.880 --> 00:07:06.979 The water is actually just flat, and the shader is very cleverly making it look 00:07:06.979 --> 00:07:12.160 like it's not flat. So, play with the properties of your water yourself, and 00:07:12.160 --> 00:07:15.509 get your water looking how you would like it to look.