1 00:00:04,120 --> 00:00:04,540 ‫All right. 2 00:00:04,540 --> 00:00:09,880 ‫So far, we have created a game which does most of the things that we need, but we can improve it a 3 00:00:09,880 --> 00:00:14,940 ‫lot by adding some effects whenever we collect a crystal. 4 00:00:14,950 --> 00:00:18,730 ‫So what I want to have is an effect whenever we run through crystal and get it. 5 00:00:18,730 --> 00:00:20,470 ‫So a little particle effect. 6 00:00:20,470 --> 00:00:25,090 ‫And in order to get a particle effect, we can create a new particle effect. 7 00:00:25,090 --> 00:00:32,740 ‫So let's click right click into the hierarchy view, then go to Effects and let's add a particle system. 8 00:00:33,250 --> 00:00:36,520 ‫So now this particle system here will be. 9 00:00:37,990 --> 00:00:38,410 ‫Added. 10 00:00:38,410 --> 00:00:40,030 ‫So let's see where it is. 11 00:00:41,390 --> 00:00:43,040 ‫Let's go to our sea view. 12 00:00:43,250 --> 00:00:44,060 ‫There it is. 13 00:00:45,200 --> 00:00:47,620 ‫And it's somewhere at the bottom there. 14 00:00:47,630 --> 00:00:49,310 ‫So let's reposition it. 15 00:00:49,310 --> 00:00:51,450 ‫Reset to zero zero. 16 00:00:51,470 --> 00:00:53,390 ‫So now it's inside of our player. 17 00:00:53,390 --> 00:00:57,200 ‫So maybe we should move it over to. 18 00:00:59,480 --> 00:01:00,530 ‫Our crystal. 19 00:01:00,530 --> 00:01:05,180 ‫So I'm going to change it and move it into our crystal now. 20 00:01:07,000 --> 00:01:09,640 ‫So the crystal is at 0.5. 21 00:01:09,640 --> 00:01:16,030 ‫I know that then the exposition should be about right and the Z position as well. 22 00:01:16,030 --> 00:01:17,350 ‫So we're about right. 23 00:01:17,350 --> 00:01:18,760 ‫It's not the perfect position. 24 00:01:18,760 --> 00:01:22,960 ‫You can play around with it and see where globally you're. 25 00:01:23,850 --> 00:01:25,790 ‫Crystallize and then set it up there. 26 00:01:25,800 --> 00:01:32,190 ‫So what this does is, as you can see, it emits particles and it constantly shoots them, as you can 27 00:01:32,190 --> 00:01:32,660 ‫see. 28 00:01:32,670 --> 00:01:36,840 ‫And actually, I changed the Y rotation. 29 00:01:37,230 --> 00:01:40,590 ‫Now let's go back and set that to zero. 30 00:01:41,010 --> 00:01:47,400 ‫Now you can see it shoots those effects out and one could think that they are 3D, but actually they 31 00:01:47,400 --> 00:01:54,420 ‫are 2D because what what they do is they simply show this 2D image following the camera. 32 00:01:54,420 --> 00:01:57,990 ‫So based on how the camera looks, they will show this 2D picture. 33 00:01:58,110 --> 00:02:06,450 ‫Now, my PC is laggy and it's lagging a little bit because effects really can decrease your performance. 34 00:02:06,630 --> 00:02:11,880 ‫And you can find out more about this when you go to the renderer in the inspector and you can find it 35 00:02:11,880 --> 00:02:13,320 ‫that it is a billboard. 36 00:02:13,320 --> 00:02:14,700 ‫So this. 37 00:02:15,540 --> 00:02:16,080 ‫Particle. 38 00:02:16,080 --> 00:02:20,510 ‫Here is a billboard and if you want to know more about it, you can open up the material. 39 00:02:20,520 --> 00:02:24,990 ‫So the default material and you find out that it's just this 2D image here. 40 00:02:25,500 --> 00:02:28,500 ‫So that's the effect that we currently see all the time in here. 41 00:02:28,530 --> 00:02:36,090 ‫Now, the cool thing is we can go ahead to our particle system and then we can change the start color. 42 00:02:36,090 --> 00:02:41,520 ‫So you can see the start color is white and we could use any color we want so we could make it red, 43 00:02:41,520 --> 00:02:45,270 ‫we could make it purple, you could make it yellow, whatever you want. 44 00:02:45,270 --> 00:02:51,090 ‫And I'm just going to use a color which we have inside of our crystal. 45 00:02:51,750 --> 00:02:54,450 ‫So that's one of the colors that we have. 46 00:02:54,450 --> 00:02:59,640 ‫And what I want to have is not only one color but a random between two colors. 47 00:02:59,640 --> 00:03:03,630 ‫So if I do that, I press right click here running between two colors. 48 00:03:03,630 --> 00:03:05,130 ‫Now I can choose. 49 00:03:06,670 --> 00:03:09,960 ‫A different colour and they will be random in between those two. 50 00:03:09,970 --> 00:03:15,820 ‫So I'm gonna choose this blue colour and now you can see there will be blue, purple, red ish. 51 00:03:15,910 --> 00:03:18,610 ‫So they will jump around between those two colours. 52 00:03:20,590 --> 00:03:24,430 ‫Now the cool thing is that we can change the emission of that particle system as well. 53 00:03:24,430 --> 00:03:30,370 ‫So as you can see now, it's constantly creating those particles and we can change that by example. 54 00:03:30,370 --> 00:03:32,020 ‫We can add a burst to it. 55 00:03:32,020 --> 00:03:33,370 ‫So let's add a burst. 56 00:03:33,370 --> 00:03:40,420 ‫And what we can do now is we can say how many bursts we want to have, how many cycles we want to have, 57 00:03:40,420 --> 00:03:41,290 ‫and so forth. 58 00:03:42,880 --> 00:03:44,440 ‫And also the interval. 59 00:03:45,590 --> 00:03:48,440 ‫I don't want them to be to have a rate over time. 60 00:03:48,440 --> 00:03:50,240 ‫So I'm going to set that to zero. 61 00:03:50,690 --> 00:03:57,410 ‫As you can see now, things changed quite a bit and it will be like a burst coming all out at the same 62 00:03:57,410 --> 00:03:59,570 ‫time with a specific duration. 63 00:03:59,570 --> 00:04:04,430 ‫So they have a lifetime of 5 seconds and I want to reduce that to 2 seconds, for example. 64 00:04:04,640 --> 00:04:08,360 ‫So now it will only be there for 2 seconds and then they will disappear. 65 00:04:08,360 --> 00:04:12,920 ‫So they have a duration of 2 seconds, but they still have a lifetime of 5 seconds. 66 00:04:12,920 --> 00:04:15,200 ‫So let's change that to, let's say 1/2. 67 00:04:15,680 --> 00:04:19,760 ‫So as you can see, it bursts and then the particles disappear. 68 00:04:21,170 --> 00:04:27,560 ‫What we, by the way, can change is maybe the X rotation to -90 and then we'll go up. 69 00:04:27,770 --> 00:04:30,200 ‫So now they will always burst up. 70 00:04:30,200 --> 00:04:33,650 ‫Then they will disappear, boom, and disappear. 71 00:04:34,370 --> 00:04:41,000 ‫Now what it does, what this particle system does here is, well, they disappear at one point, so 72 00:04:41,000 --> 00:04:42,170 ‫it doesn't look that great. 73 00:04:42,170 --> 00:04:42,630 ‫Right. 74 00:04:42,650 --> 00:04:43,730 ‫We can change that. 75 00:04:43,730 --> 00:04:46,850 ‫And as well, we can change the form in which it comes out. 76 00:04:46,850 --> 00:04:51,620 ‫So the shape, as you can see, there is a shape and the shape currently is a cone. 77 00:04:51,620 --> 00:04:54,410 ‫But we can change that to, for example, a sphere. 78 00:04:54,410 --> 00:05:00,920 ‫So if we want them to be created within a sphere, we can do that and we can also resize it. 79 00:05:00,920 --> 00:05:02,930 ‫So let's change the size a little bit. 80 00:05:02,930 --> 00:05:05,720 ‫Let's bring it down to like this size. 81 00:05:05,720 --> 00:05:10,730 ‫So it will come from this little sphere here in the center, and then it will create those bursts of 82 00:05:10,730 --> 00:05:13,340 ‫emissions on those particles. 83 00:05:13,730 --> 00:05:15,500 ‫But that's not the only thing we can change. 84 00:05:15,500 --> 00:05:18,770 ‫We can change the shape, we can change the radius and so on. 85 00:05:18,770 --> 00:05:25,220 ‫But what I want to change as well is that it doesn't disappear straight away, but it fades away and 86 00:05:25,220 --> 00:05:28,340 ‫we can do that with colour over lifetime. 87 00:05:28,340 --> 00:05:29,960 ‫So currently. 88 00:05:31,230 --> 00:05:32,970 ‫It just has this empty color. 89 00:05:32,970 --> 00:05:35,070 ‫So let's activate it. 90 00:05:36,320 --> 00:05:37,880 ‫And now it's just white. 91 00:05:39,510 --> 00:05:43,950 ‫So let's double click here and then the gradient editor opens. 92 00:05:43,950 --> 00:05:51,090 ‫And what you can do here now is so click on this little button over here or this little piece over here, 93 00:05:51,150 --> 00:05:53,640 ‫and then let's change the Alpha to zero. 94 00:05:53,640 --> 00:06:00,300 ‫So you can see that it will go now from having 250 504 to 0 Alpha over time. 95 00:06:00,300 --> 00:06:01,470 ‫So let's simulate it. 96 00:06:01,470 --> 00:06:04,530 ‫And as you can see now, it fades away step by step. 97 00:06:05,430 --> 00:06:08,910 ‫Now I can go ahead and change the particle system even further. 98 00:06:08,910 --> 00:06:12,900 ‫You can, for example, change the size over lifetime. 99 00:06:12,900 --> 00:06:22,380 ‫So if we would want it to get bigger over lifetime or we could go from big to small, or we could go 100 00:06:22,380 --> 00:06:26,210 ‫from small to big as you like, you can play around with the values here. 101 00:06:26,220 --> 00:06:29,460 ‫It could start off and then it would change over time. 102 00:06:29,460 --> 00:06:35,220 ‫So there are multiple different versions that you can use for size of a lifetime, but I'm just going 103 00:06:35,220 --> 00:06:36,270 ‫to deactivate that. 104 00:06:36,570 --> 00:06:39,330 ‫And of course you can play around with all of those things here. 105 00:06:39,330 --> 00:06:40,920 ‫For example, also the noise. 106 00:06:40,920 --> 00:06:42,060 ‫You can have a noise. 107 00:06:42,060 --> 00:06:44,880 ‫As you can see now, it floats into different directions. 108 00:06:44,880 --> 00:06:50,940 ‫It's not so easy to see here because it's a bit laggy, but other than that, you can change the noise 109 00:06:50,940 --> 00:06:51,150 ‫here. 110 00:06:51,150 --> 00:06:54,660 ‫For example, you can change the strength so that the noise is not as strong. 111 00:06:54,660 --> 00:07:01,560 ‫So now it looks a little bit like there is a wind which floats randomly and changes to particle system. 112 00:07:02,340 --> 00:07:04,590 ‫Next, let's randomize some of the things. 113 00:07:04,590 --> 00:07:08,790 ‫So for now we have a start lifetime of 1/2. 114 00:07:08,790 --> 00:07:14,160 ‫Maybe we should reduce that to 0.5 seconds so that it doesn't go as far. 115 00:07:14,250 --> 00:07:17,610 ‫Then we can change the start size. 116 00:07:17,610 --> 00:07:24,500 ‫We could go ahead and use a random between two constants so the size could be between 0.1 and 0.5, 117 00:07:24,510 --> 00:07:25,440 ‫for example. 118 00:07:25,950 --> 00:07:28,500 ‫So now it's a bit smaller. 119 00:07:28,500 --> 00:07:30,990 ‫They're a bit well, a bit more controlled. 120 00:07:30,990 --> 00:07:32,070 ‫Then it start speed. 121 00:07:32,070 --> 00:07:33,300 ‫We could even do that. 122 00:07:33,300 --> 00:07:37,620 ‫We can even change the start speed a little bit random between two constants. 123 00:07:37,620 --> 00:07:41,760 ‫So let's go here between 1.5 and two. 124 00:07:41,790 --> 00:07:45,510 ‫So now the speed is randomized of those particles. 125 00:07:45,840 --> 00:07:48,450 ‫So you can see you can randomize many things here. 126 00:07:51,390 --> 00:07:55,200 ‫It's a lot about playing around and seeing what you like, what looks best for you. 127 00:07:55,200 --> 00:08:00,780 ‫So maybe point two and point four would be a better choice. 128 00:08:00,790 --> 00:08:06,720 ‫So the idea behind it is that you find something that looks great and just does the job and that you 129 00:08:06,720 --> 00:08:07,530 ‫really like. 130 00:08:07,920 --> 00:08:11,160 ‫Now let's set the lifetime random as well. 131 00:08:11,160 --> 00:08:14,400 ‫So random between two constants for the lifetime. 132 00:08:14,400 --> 00:08:20,550 ‫And let's go to 1.5 to 2 seconds. 133 00:08:20,550 --> 00:08:21,810 ‫Let's see how that looks. 134 00:08:24,070 --> 00:08:28,150 ‫Maybe it's a bit too big, so go 0.5 and one. 135 00:08:28,630 --> 00:08:31,660 ‫So now we all have a lifetime, which is random for each particle. 136 00:08:33,400 --> 00:08:39,880 ‫You could even go ahead and create your very own effects so you can simply create a your own billboard. 137 00:08:39,880 --> 00:08:44,140 ‫Or you can yeah, you can simply use an own image that you have here. 138 00:08:44,140 --> 00:08:50,950 ‫So as you can see, it's just a 64 times 64, 32 bit default particle, which is just a file, and you 139 00:08:50,950 --> 00:08:55,690 ‫could create a circle yourself and yeah, you can set it up as you like. 140 00:08:56,050 --> 00:08:56,650 ‫All right. 141 00:08:56,650 --> 00:09:03,850 ‫So now let's save that particle system and let's rename it first and call it crystal effect. 142 00:09:04,730 --> 00:09:07,330 ‫Now let's drag that into our prefabs. 143 00:09:07,330 --> 00:09:10,930 ‫So let's drag the crystal effect into our preset prefabs. 144 00:09:11,020 --> 00:09:15,550 ‫Now, we can get rid of that crystal effect because we have it as an as a prefab. 145 00:09:15,550 --> 00:09:16,900 ‫So let's delete that. 146 00:09:16,900 --> 00:09:19,720 ‫And now let's go into the character script. 147 00:09:19,720 --> 00:09:23,260 ‫So here character and. 148 00:09:24,000 --> 00:09:31,700 ‫Chart controller and create a public game object crystal effect. 149 00:09:33,840 --> 00:09:34,800 ‫Well, let's save that. 150 00:09:34,830 --> 00:09:37,920 ‫Now, let's set that into our character. 151 00:09:37,920 --> 00:09:42,960 ‫So after a couple of seconds, we should see that here, the crystal. 152 00:09:44,220 --> 00:09:44,970 ‫Affect. 153 00:09:46,490 --> 00:09:47,000 ‫That we are. 154 00:09:47,030 --> 00:09:48,050 ‫Crystal effect. 155 00:09:48,320 --> 00:09:54,920 ‫Let's go to assets prefabs, which is our character again and drag the crystal effect in there. 156 00:09:54,950 --> 00:09:57,470 ‫Now let's go back to our script. 157 00:10:00,240 --> 00:10:01,800 ‫And set that up. 158 00:10:01,800 --> 00:10:04,540 ‫So when do we want the crystal effect to be shown? 159 00:10:04,560 --> 00:10:09,420 ‫Well, whenever we collide or whenever Trigger Enter is called. 160 00:10:09,420 --> 00:10:11,320 ‫So whenever we hit a crystal. 161 00:10:11,340 --> 00:10:18,600 ‫So the means within this if statement, we want to go ahead and create a game object called G and instantiate 162 00:10:18,600 --> 00:10:19,050 ‫that. 163 00:10:19,260 --> 00:10:21,200 ‫And what do we want to instantiate? 164 00:10:21,210 --> 00:10:24,900 ‫Well, we want to instantiate our crystal effect game object. 165 00:10:24,900 --> 00:10:30,720 ‫And where do we want to instantiate it at transform dot position. 166 00:10:30,720 --> 00:10:39,690 ‫So at the position of our player and as the criterion, we just set up criterion dot identity. 167 00:10:40,950 --> 00:10:43,170 ‫So no rotation. 168 00:10:43,170 --> 00:10:49,050 ‫Then we destroy that game object g after a lifetime of 2 seconds. 169 00:10:49,050 --> 00:10:52,740 ‫So we just say you live for 2 seconds and then that's enough. 170 00:10:53,520 --> 00:10:58,050 ‫And now we of course may not forget to destroy our crystal itself. 171 00:10:58,050 --> 00:11:00,720 ‫And we do that here at the bottom. 172 00:11:00,720 --> 00:11:04,740 ‫So we create our crystal effect at the feet of our player. 173 00:11:04,740 --> 00:11:10,170 ‫Then we destroy it after a couple of seconds of the 2 seconds, to be precise, and then we destroy 174 00:11:10,170 --> 00:11:11,310 ‫the crystal as well. 175 00:11:11,310 --> 00:11:14,040 ‫We don't do that after 2 seconds, we do it straight away. 176 00:11:16,140 --> 00:11:21,660 ‫So now let's save that script and let's go into our game and let's have a look what happens. 177 00:11:25,370 --> 00:11:26,480 ‫So now let's press enter. 178 00:11:26,480 --> 00:11:31,520 ‫And as you can see, there is this crystal effect which does what it should. 179 00:11:32,630 --> 00:11:38,820 ‫Maybe it's a bit too big, but whatever you could change it and well, change it to your pleasing or 180 00:11:38,840 --> 00:11:39,680 ‫to your liking. 181 00:11:40,040 --> 00:11:46,010 ‫What we could, of course, do is start the particle effect, not at the feet of our player, which 182 00:11:46,010 --> 00:11:49,310 ‫happens now, but at the centre of our player. 183 00:11:49,310 --> 00:11:52,250 ‫So it could be at the chest of our player. 184 00:11:52,250 --> 00:11:54,280 ‫And what was it, the chest of our player? 185 00:11:54,290 --> 00:11:55,910 ‫Well, our race start. 186 00:11:56,670 --> 00:11:57,420 ‫Game object. 187 00:11:57,420 --> 00:11:58,770 ‫So we could do that. 188 00:11:59,310 --> 00:12:05,160 ‫Let's have a look at how and here we don't do the transform position, but we check the. 189 00:12:06,520 --> 00:12:08,530 ‫Ray start transform positions. 190 00:12:08,530 --> 00:12:13,810 ‫So let's go to ray start dot transform dot position. 191 00:12:13,810 --> 00:12:16,510 ‫And actually it was called like that. 192 00:12:16,720 --> 00:12:19,090 ‫So now let's see what happens. 193 00:12:19,090 --> 00:12:21,910 ‫Let's go to our character and. 194 00:12:22,870 --> 00:12:24,130 ‫It has a started already. 195 00:12:24,130 --> 00:12:24,820 ‫That's perfect. 196 00:12:24,820 --> 00:12:25,900 ‫So now let's have a look. 197 00:12:27,920 --> 00:12:31,790 ‫And you can see now it comes from roughly the chest. 198 00:12:31,790 --> 00:12:34,790 ‫So the center body or center point of our player. 199 00:12:35,180 --> 00:12:35,600 ‫Great. 200 00:12:35,600 --> 00:12:37,210 ‫So that about effects. 201 00:12:37,220 --> 00:12:39,460 ‫Of course, you can play around with effects. 202 00:12:39,470 --> 00:12:44,390 ‫You can check out every single detail of these effect settings and play around with them. 203 00:12:44,390 --> 00:12:46,850 ‫And then you will see that there is plenty to do. 204 00:12:46,850 --> 00:12:50,690 ‫And in the end, it's all about how it fits into your game. 205 00:12:52,040 --> 00:12:55,280 ‫In the next video, we will have a look at it. 206 00:12:55,310 --> 00:12:57,350 ‫Setting up background music for our game.