﻿1
00:00:04,310 --> 00:00:04,700
‫Okay.

2
00:00:04,700 --> 00:00:08,630
‫So we'd like to see an explosion when one of the pawns dies.

3
00:00:08,630 --> 00:00:12,710
‫So if I destroy a tower here, there's the explosion.

4
00:00:12,710 --> 00:00:17,540
‫And if the tower destroys me, I can boom, blow up.

5
00:00:17,690 --> 00:00:18,840
‫Welcome back.

6
00:00:18,860 --> 00:00:24,530
‫Now, we've been implementing some special effects, and the next special effect we'd like to implement

7
00:00:24,530 --> 00:00:27,630
‫are some hit particles that will cause an explosion.

8
00:00:27,650 --> 00:00:32,080
‫On death, this means death for the tower or death for the tank.

9
00:00:32,090 --> 00:00:37,390
‫So since this will be implemented for each pawn, inheritance should come to mind.

10
00:00:37,400 --> 00:00:40,850
‫So for these death particles, let's form a game plan.

11
00:00:40,880 --> 00:00:46,070
‫First, we need to add a new particle system pointer, and we're going to add this to the base pond

12
00:00:46,070 --> 00:00:53,730
‫class because we'd like the explosion effect to happen when either the tank or the tower gets destroyed.

13
00:00:53,750 --> 00:00:57,470
‫Next, we're going to spawn an emitter on death.

14
00:00:57,500 --> 00:01:03,860
‫Now, the base pawn class has its own version of handle destruction, and that's called in both the

15
00:01:03,860 --> 00:01:06,320
‫tank and the tower using super.

16
00:01:06,320 --> 00:01:13,400
‫So because this is implemented in base pawn, whatever we put in this function in based pawn will happen

17
00:01:13,400 --> 00:01:15,080
‫for the tank and the tower.

18
00:01:15,080 --> 00:01:19,760
‫So we know how to spawn emitters at location using new gameplay statics.

19
00:01:19,760 --> 00:01:21,290
‫So that should be pretty easy.

20
00:01:21,320 --> 00:01:27,230
‫Now the last thing will be to set the particle system in blueprints and we have a p underscore death

21
00:01:27,230 --> 00:01:33,350
‫effect particle system that we can set this to, which means our particle system pointer needs to be

22
00:01:33,350 --> 00:01:39,560
‫exposed with U property and set to be editable, whether it's edit anywhere or edit defaults only.

23
00:01:39,650 --> 00:01:42,740
‫And these are all things that you have experience doing.

24
00:01:42,740 --> 00:01:45,350
‫So this is going to be your challenge.

25
00:01:45,350 --> 00:01:47,390
‫Add the particle system variable.

26
00:01:47,390 --> 00:01:53,750
‫Add this to base pawn because we want to inherit this functionality in the tank and the tower next spawn

27
00:01:53,780 --> 00:01:59,960
‫the emitter we saw that handle destruction in the base pawn class is the perfect place to do this.

28
00:01:59,960 --> 00:02:05,330
‫And next you're going to set the particle system in blueprints since you're going to make this particle

29
00:02:05,330 --> 00:02:08,990
‫system variable exposed to the blueprint editor.

30
00:02:08,990 --> 00:02:13,850
‫So pause the video and implement death particles on your own now.

31
00:02:17,260 --> 00:02:17,680
‫Okay.

32
00:02:17,680 --> 00:02:24,010
‫So let's go into the base -- header file and we can add a new particle system variable.

33
00:02:24,010 --> 00:02:30,430
‫This is going to be private and it's going to be forward declared and the type will be you particle

34
00:02:30,430 --> 00:02:32,200
‫system pointer.

35
00:02:32,200 --> 00:02:34,780
‫And I'm going to call this death particles.

36
00:02:34,780 --> 00:02:39,040
‫Now, we need to expose this so we can set it from the blueprint editor.

37
00:02:39,040 --> 00:02:47,650
‫So I'm going to make this a U property edit anywhere category and I'm just going to place this in combat.

38
00:02:47,950 --> 00:02:49,270
‫There we go.

39
00:02:49,270 --> 00:02:56,290
‫So now we're going to have a particle system and we need to spawn this and handle destruction.

40
00:02:56,290 --> 00:03:01,030
‫So let's go to base upon CP and find handle destruction.

41
00:03:01,030 --> 00:03:01,810
‫And here it is.

42
00:03:01,810 --> 00:03:05,470
‫We even have a To-Do here that says visual and sound effects.

43
00:03:05,470 --> 00:03:08,890
‫So we're taking care of visual effects right now.

44
00:03:08,890 --> 00:03:12,790
‫Now spawn emitter at location is a gameplay statics function.

45
00:03:12,790 --> 00:03:14,650
‫So we need gameplay statics here.

46
00:03:14,650 --> 00:03:20,980
‫And I remember just from doing this so much that it's in kismet slash gameplay statics.

47
00:03:21,820 --> 00:03:26,020
‫Now we also need the proper include for a U particle system.

48
00:03:26,020 --> 00:03:27,910
‫So here's my documentation.

49
00:03:27,910 --> 00:03:34,510
‫It's open and I'm going to search for you particle system and here is you particle system and I can

50
00:03:34,510 --> 00:03:41,740
‫scroll down to the include and it's particles slash particle system dot h so I'm going to include that

51
00:03:41,740 --> 00:03:42,760
‫as well.

52
00:03:42,760 --> 00:03:52,120
‫And now I can call spawn emitter at location using U gameplay statics spawn emitter at location.

53
00:03:52,450 --> 00:03:55,540
‫Now we saw that with the overload we used before.

54
00:03:55,540 --> 00:04:03,580
‫We could use this for a world context object and next we needed to pass in a particle system.

55
00:04:03,580 --> 00:04:06,040
‫And for this we have death particles.

56
00:04:06,040 --> 00:04:09,460
‫So I'm going to pass that in death particles.

57
00:04:09,970 --> 00:04:16,540
‫Next, we need a location and for the base pond I'm going to pass and get actor location and for the

58
00:04:16,540 --> 00:04:19,990
‫rotation, get actor rotation.

59
00:04:20,200 --> 00:04:22,740
‫And it's as simple as that.

60
00:04:22,750 --> 00:04:28,210
‫Now before I compile, I'd like to check to make sure death particles is not a null pointer.

61
00:04:28,210 --> 00:04:35,380
‫So I'm going to first check to see if death particles, if that is valid, then I'm going to call spawn

62
00:04:35,380 --> 00:04:36,460
‫emitter at location.

63
00:04:36,460 --> 00:04:41,740
‫So I'm going to move that just inside my if check and now I'm going to compile.

64
00:04:41,770 --> 00:04:42,280
‫Okay.

65
00:04:42,280 --> 00:04:50,110
‫So I'm back here in the editor and the next thing to do is I need to go and set this particle system

66
00:04:50,110 --> 00:04:53,440
‫in my blueprints both for the pawn and the turret.

67
00:04:53,470 --> 00:04:56,260
‫So I'm going to open up BP pawn tank.

68
00:04:56,260 --> 00:04:59,800
‫And here in the combat section I have death particles.

69
00:04:59,800 --> 00:05:06,550
‫And before I set it, I'm going to go into the assets and effects folder and check out Death Effect,

70
00:05:06,550 --> 00:05:10,780
‫and we can see that it looks like a cool little explosion.

71
00:05:10,780 --> 00:05:12,160
‫So I'm going to set that.

72
00:05:12,160 --> 00:05:14,830
‫So let's go back into BP Pond Tank.

73
00:05:14,830 --> 00:05:16,360
‫Here's the combat section.

74
00:05:16,360 --> 00:05:23,260
‫Remember, I have BP Pond Tank self selected to see these variables and here's death particles and I'm

75
00:05:23,260 --> 00:05:29,920
‫going to select p underscore death effect and I'll compile save and close that.

76
00:05:29,920 --> 00:05:35,110
‫Now that takes care of the death effect for when the tank dies, but we also need to set it for the

77
00:05:35,110 --> 00:05:35,770
‫tower.

78
00:05:35,770 --> 00:05:43,000
‫So let's go into ponds, open BP pond, turret, and here's the combat section, here's death particles.

79
00:05:43,000 --> 00:05:46,270
‫Let's click the dropdown and select death effect.

80
00:05:46,300 --> 00:05:52,360
‫Now we can compile, save and close out of that and we're ready to test this out.

81
00:05:52,360 --> 00:05:59,380
‫I'm going to go to a second viewport by going to Window Viewport Viewport two, and here's a nice full

82
00:05:59,380 --> 00:06:01,330
‫screen viewport for me.

83
00:06:01,330 --> 00:06:05,110
‫I'm going to hit alt p and that will start the game for me.

84
00:06:05,110 --> 00:06:11,470
‫So now I'm ready to start the game and I'm going to try to first destroy a couple of these towers.

85
00:06:11,470 --> 00:06:12,760
‫So let's boom.

86
00:06:12,760 --> 00:06:13,390
‫There we go.

87
00:06:13,390 --> 00:06:14,050
‫I did it.

88
00:06:14,050 --> 00:06:16,870
‫And I'm going to go ahead and destroy another one.

89
00:06:16,870 --> 00:06:19,840
‫And let's see if the towers can destroy me.

90
00:06:20,910 --> 00:06:23,130
‫Boehme and I lost.

91
00:06:23,670 --> 00:06:24,570
‫Excellent.

92
00:06:25,250 --> 00:06:32,090
‫So in summary, we now have death particles, which is a nice explosion that occurs when one of the

93
00:06:32,090 --> 00:06:33,150
‫ponds dies.

94
00:06:33,170 --> 00:06:37,130
‫We're making great progress and we're almost done with this section.

95
00:06:37,340 --> 00:06:39,050
‫I'll see you in the next video.

