﻿1
00:00:04,440 --> 00:00:06,210
‫Hello and welcome back.

2
00:00:06,240 --> 00:00:09,160
‫Now we're ready to create a projectile class.

3
00:00:09,180 --> 00:00:15,510
‫Now our tanks and our towers need to fire projectiles, which means that we're going to need a C++ class

4
00:00:15,510 --> 00:00:16,950
‫for the projectile.

5
00:00:16,980 --> 00:00:22,800
‫Now, the projectile is going to need its own static mesh so that we can see the projectile once we

6
00:00:22,800 --> 00:00:24,250
‫spawn it in the world.

7
00:00:24,270 --> 00:00:29,730
‫So we're going to create the C++ class and then we'll create a blueprint based on this class.

8
00:00:29,730 --> 00:00:34,380
‫And this is going to be a challenge for you since these are all things that you already know how to

9
00:00:34,380 --> 00:00:35,090
‫do.

10
00:00:35,100 --> 00:00:40,180
‫So you're going to create a new C++ class and choose the correct parent class.

11
00:00:40,200 --> 00:00:45,360
‫Now, the projectile doesn't need to handle any user input, so that should tell you right there that

12
00:00:45,360 --> 00:00:47,410
‫this is not going to be a --.

13
00:00:47,430 --> 00:00:53,930
‫Now, once you've done this, add a static mesh variable just like we've done for our other classes,

14
00:00:53,940 --> 00:01:00,180
‫construct it in the constructor using create default sub object and set the static mesh as the root

15
00:01:00,180 --> 00:01:00,890
‫component.

16
00:01:00,900 --> 00:01:06,630
‫Now once you're done, go ahead and create a blueprint based on this projectile class.

17
00:01:06,630 --> 00:01:11,730
‫And in the blueprint, set the static mesh property for the static mesh component.

18
00:01:11,730 --> 00:01:15,540
‫Pause the video and create the projectile class now.

19
00:01:18,410 --> 00:01:18,570
‫Okay.

20
00:01:18,730 --> 00:01:22,060
‫So we're ready to create the projectile C++ class.

21
00:01:22,060 --> 00:01:25,450
‫So I'm going to go to file new C++ class.

22
00:01:25,450 --> 00:01:30,370
‫And because we don't need user input, this is just going to be a basic actor.

23
00:01:30,370 --> 00:01:35,890
‫An actor can be placed in the world or spawned in the world, and we're going to be spawning these in

24
00:01:35,890 --> 00:01:36,340
‫the world.

25
00:01:36,340 --> 00:01:39,160
‫So we need to derive from the actor class.

26
00:01:39,250 --> 00:01:42,250
‫I'm going to click next and name this new class.

27
00:01:42,250 --> 00:01:43,600
‫Now this is a projectile.

28
00:01:43,600 --> 00:01:47,500
‫So I think projectile is a perfect name for this.

29
00:01:47,500 --> 00:01:52,990
‫I'm going to leave it in the same folder as all our other C++ classes and click Create Class.

30
00:01:52,990 --> 00:02:00,040
‫So here we have projectile FX and projectile CP and we need to add a static mesh variable.

31
00:02:00,040 --> 00:02:04,090
‫So I'm going to add a private section just under the protected one.

32
00:02:04,090 --> 00:02:09,820
‫So private and we're going to need a U static mesh component.

33
00:02:09,820 --> 00:02:13,330
‫So this would be a U static mesh component.

34
00:02:14,140 --> 00:02:15,760
‫It's going to be a pointer.

35
00:02:15,760 --> 00:02:16,630
‫Now, that's okay.

36
00:02:16,630 --> 00:02:20,560
‫If you named it something different, I'm going to call this projectile mesh.

37
00:02:20,890 --> 00:02:24,340
‫Now we're going to expose this using you property.

38
00:02:24,340 --> 00:02:25,900
‫So you property.

39
00:02:25,900 --> 00:02:30,400
‫And I'd like to be able to edit this from the default blueprint.

40
00:02:30,400 --> 00:02:34,750
‫So I think edit defaults only is appropriate for this.

41
00:02:35,110 --> 00:02:39,430
‫I'm going to give it a category and the category can be combat.

42
00:02:39,490 --> 00:02:44,680
‫It's not really important what we call it, and that's all the exposure I'm going to give this variable.

43
00:02:44,680 --> 00:02:47,740
‫That's okay if you have different you property settings here.

44
00:02:47,740 --> 00:02:49,210
‫Now we need to construct this.

45
00:02:49,210 --> 00:02:58,480
‫So let's go into projectile CP into the constructor and say projectile mesh and we're going to call

46
00:02:58,480 --> 00:03:04,180
‫create default sub object using u static mesh component.

47
00:03:05,230 --> 00:03:09,580
‫And for the text, I'm just going to say projectile mesh.

48
00:03:09,670 --> 00:03:13,390
‫And finally, we need to set this to be the root component.

49
00:03:13,390 --> 00:03:21,550
‫So I'm going to say root component equals projectile mesh and I'm going to spell it correctly there.

50
00:03:21,580 --> 00:03:22,210
‫Okay.

51
00:03:22,210 --> 00:03:25,360
‫So that takes care of the C++ side of things.

52
00:03:25,360 --> 00:03:31,990
‫Now, you may not have thought of this, but we have this primary actor tic b can never tic equals true.

53
00:03:31,990 --> 00:03:37,030
‫And because our projectile doesn't really need to tic, we can set this to fall.

54
00:03:37,030 --> 00:03:41,680
‫So if you'd like, go ahead and set that to false along with me here.

55
00:03:41,680 --> 00:03:46,540
‫And we do get the red squiggles here under the assignment operator.

56
00:03:46,540 --> 00:03:52,180
‫And this is simply because we need to include the header file for you static mesh components.

57
00:03:52,180 --> 00:03:58,780
‫So if we go to based upon CP, we can see that header file here because we needed to include it for

58
00:03:58,780 --> 00:04:01,180
‫the static mesh components in the base pod.

59
00:04:01,180 --> 00:04:05,080
‫So I'm going to steal that, include and paste it right here at the top.

60
00:04:05,080 --> 00:04:08,260
‫And that way you a static mesh component is defined.

61
00:04:08,260 --> 00:04:13,690
‫Now let's go ahead and compile this and I'm back here in the editor and the next thing we need to do

62
00:04:13,690 --> 00:04:16,690
‫is create a blueprint based on projectile.

63
00:04:16,690 --> 00:04:20,800
‫Now I'm going to go into the blueprints folder and we have a pawns folder.

64
00:04:20,800 --> 00:04:27,370
‫I'd like to create a new folder and call this actors because our projectile is not a pawn, so it doesn't

65
00:04:27,370 --> 00:04:29,530
‫really need to go into the pawns folder.

66
00:04:29,530 --> 00:04:31,240
‫So we have a new actors folder.

67
00:04:31,240 --> 00:04:37,960
‫I'm going to go into it and this time I can right click and select Blueprint Class and here we can select

68
00:04:37,960 --> 00:04:40,660
‫the class to base this blueprint on.

69
00:04:40,660 --> 00:04:46,930
‫If we click the dropdown next to all classes, then we can search for projectile and there is the projectile

70
00:04:46,930 --> 00:04:47,380
‫class.

71
00:04:47,380 --> 00:04:50,170
‫So I'm going to select that click select.

72
00:04:50,170 --> 00:04:53,530
‫And now we have a new blueprint based on the projectile class.

73
00:04:53,530 --> 00:04:58,330
‫So that's another way to create a blueprint based on one of our C++ classes.

74
00:04:58,330 --> 00:05:04,690
‫Now I'm going to call this B.P. underscore projectile and I'm going to double click to open up Beep

75
00:05:04,690 --> 00:05:08,050
‫Projectile and I'll click Open Full Blueprint Editor.

76
00:05:08,050 --> 00:05:10,150
‫If you see that, go ahead and click on it.

77
00:05:10,150 --> 00:05:13,780
‫And we have our blueprint and here's projectile mesh.

78
00:05:13,780 --> 00:05:17,530
‫And by default it doesn't have its static mesh property set.

79
00:05:17,530 --> 00:05:21,490
‫So we're going to set that and I'm going to choose the SM projectile.

80
00:05:21,490 --> 00:05:25,480
‫I'm sure that is what you selected for your projectile.

81
00:05:25,480 --> 00:05:26,380
‫Makes sense.

82
00:05:26,380 --> 00:05:27,940
‫So we have a projectile.

83
00:05:27,940 --> 00:05:28,630
‫Excellent.

84
00:05:28,630 --> 00:05:35,230
‫I'm going to compile and save this close out of it and click save all just to make sure everything is

85
00:05:35,230 --> 00:05:37,480
‫saved and we now have a projectile.

86
00:05:37,480 --> 00:05:44,110
‫So in summary, you have created your projectile class and you created a blueprint based on projectile

87
00:05:44,110 --> 00:05:46,930
‫and gave it a use static mesh component variable.

88
00:05:46,930 --> 00:05:49,840
‫And in the blueprint you set it's static mesh.

89
00:05:49,840 --> 00:05:52,630
‫So now we have a projectile to work with.

90
00:05:52,630 --> 00:05:57,820
‫We're ready to start spawning these things and we're going to take care of that in the next video.

91
00:05:57,820 --> 00:05:58,690
‫I'll see you soon.

