﻿1
00:00:04,110 --> 00:00:07,740
‫In this lecture, we're going to create a C++ class.

2
00:00:07,770 --> 00:00:11,310
‫Now we need a class that we can use for our pawns.

3
00:00:11,340 --> 00:00:15,720
‫Now I'm saying pawns, plural, because there will be two different pawns in our game.

4
00:00:15,720 --> 00:00:20,280
‫There's going to be the tank that we use to roll around the level, and there's going to be a turret

5
00:00:20,280 --> 00:00:24,870
‫which will be our enemy so we can create a base pawn class.

6
00:00:24,870 --> 00:00:30,050
‫And this is going to have the basic functionality that both the tank and the turret will share.

7
00:00:30,060 --> 00:00:34,890
‫And this way we can create our two child classes, the tank and the turret.

8
00:00:34,890 --> 00:00:40,890
‫So these are going to inherit qualities from the base pawn class and these are things that both pawns

9
00:00:40,890 --> 00:00:47,010
‫are going to share, such as having the mesh, having a capsule component and the ability to launch

10
00:00:47,010 --> 00:00:47,820
‫projectiles.

11
00:00:47,820 --> 00:00:51,840
‫Now, we're going to get into all those features in future videos for this video.

12
00:00:51,840 --> 00:00:56,280
‫We're just going to create the C++ class and add some basic variables to it.

13
00:00:56,280 --> 00:01:00,990
‫So this is our motivation for creating our first C++ class.

14
00:01:01,020 --> 00:01:06,450
‫Now we're ready to start creating some C++ classes for this project.

15
00:01:06,630 --> 00:01:13,410
‫Now you'll see down here in the content browser that there are no folders for C++ classes.

16
00:01:13,410 --> 00:01:19,770
‫That's because we haven't created any just yet, but we're about to write now so we can go up to tools

17
00:01:19,770 --> 00:01:22,140
‫and select new C++ class.

18
00:01:22,140 --> 00:01:27,690
‫And here is where we're going to choose the parent class for the class that we're going to create.

19
00:01:27,690 --> 00:01:31,740
‫And by default, we have several options here to choose from.

20
00:01:31,740 --> 00:01:35,330
‫This is something that you should have seen in previous lectures.

21
00:01:35,330 --> 00:01:38,280
‫So now we have some decisions to make here.

22
00:01:38,370 --> 00:01:41,550
‫For one, which parent class are we going to choose?

23
00:01:41,550 --> 00:01:42,210
‫We have.

24
00:01:42,210 --> 00:01:43,860
‫The first one is none.

25
00:01:43,860 --> 00:01:50,910
‫That would basically allow us to create a plain old C++ class, but we're going to need some extra functionality.

26
00:01:50,910 --> 00:01:55,440
‫For one, we want to be able to place an instance of this object in the world.

27
00:01:55,440 --> 00:01:58,230
‫So we can't do that with a plain old C++ class.

28
00:01:58,230 --> 00:02:03,810
‫We could do that with a character or a pawn or an actor, but which one of these is most appropriate

29
00:02:03,810 --> 00:02:05,250
‫for what we want to do?

30
00:02:05,400 --> 00:02:10,020
‫Well, we need to take a step back and think about what exactly we're trying to create here.

31
00:02:10,050 --> 00:02:17,460
‫We're trying to create a tank that we can control and move around the level and shoot projectiles so

32
00:02:17,460 --> 00:02:21,570
‫that we can cause damage and all that good stuff in our assets folder.

33
00:02:21,570 --> 00:02:28,770
‫Just to remind us, we have this meshes folder here and we have the tank base and we have the tank turret.

34
00:02:28,800 --> 00:02:32,670
‫These are two different meshes that are going to be in our class.

35
00:02:32,670 --> 00:02:35,640
‫And so we need the capability to have meshes.

36
00:02:35,640 --> 00:02:39,270
‫And so a plain C++ class does not have that ability.

37
00:02:39,540 --> 00:02:41,670
‫So let's think about this for a second.

38
00:02:41,670 --> 00:02:44,250
‫What parent class should we use?

39
00:02:44,250 --> 00:02:48,780
‫Well, the first class that should probably come to your mind is the actor class.

40
00:02:48,780 --> 00:02:52,320
‫Now, the actor class has the ability to be placed in the world.

41
00:02:52,320 --> 00:02:53,850
‫So that's a great start.

42
00:02:53,940 --> 00:02:57,750
‫It also has the ability to have a visual representation.

43
00:02:57,750 --> 00:03:04,080
‫Whether that's a mesh or anything else, it can actually be seen once you place it in the world, provided

44
00:03:04,080 --> 00:03:07,650
‫that you give it a mesh or whatever it is that you want to see.

45
00:03:07,650 --> 00:03:13,260
‫Now derived from actor, we have the -- class and the -- inherits all of those qualities from the

46
00:03:13,260 --> 00:03:19,830
‫actor class, except it has additional qualities such as the ability to be possessed by a controller.

47
00:03:19,830 --> 00:03:25,980
‫Now this whole possession thing is something that will go into more detail about later, but for now,

48
00:03:25,980 --> 00:03:30,060
‫just understand that this means a -- can be controlled by a player.

49
00:03:30,060 --> 00:03:36,750
‫So if you're pressing a mouse button or a keyboard key, this can be set up and configured so that we

50
00:03:36,750 --> 00:03:38,580
‫can move the -- around.

51
00:03:38,580 --> 00:03:43,110
‫So this sounds like something that we would definitely want for our tank.

52
00:03:43,110 --> 00:03:49,410
‫So by handling movement input, the -- is sounding like a pretty good choice now derived from the

53
00:03:49,410 --> 00:03:55,560
‫-- class and thus inheriting all the stuff that the -- has, plus all the stuff that the -- inherited

54
00:03:55,560 --> 00:03:56,880
‫from its parent class.

55
00:03:56,880 --> 00:04:02,100
‫We have the character class which has some character specific stuff.

56
00:04:02,460 --> 00:04:05,550
‫For example, it has something called a character movement component.

57
00:04:05,550 --> 00:04:07,830
‫Now, a -- does not have this.

58
00:04:07,860 --> 00:04:13,980
‫A character movement component gives the character extra abilities such as different movement modes

59
00:04:13,980 --> 00:04:19,440
‫like flying and swimming and crouching and other stuff specific to characters.

60
00:04:19,440 --> 00:04:25,560
‫The character class is good for bipedal characters and it's not going to work very well for non bipedal

61
00:04:25,560 --> 00:04:28,410
‫characters things that are not creatures with two legs.

62
00:04:28,410 --> 00:04:34,050
‫And although it would be pretty awesome to have a tank flying around the level and dropping bombs on

63
00:04:34,050 --> 00:04:38,940
‫everything it sees, we're not going to do quite anything that complicated in this section.

64
00:04:38,940 --> 00:04:41,040
‫We're just going to make a tank that can roll around.

65
00:04:41,040 --> 00:04:47,220
‫So we really don't need a character movement component or any of that special character specific stuff.

66
00:04:47,220 --> 00:04:52,380
‫So for this, I think a -- is perfect for what we're trying to achieve.

67
00:04:52,380 --> 00:04:59,490
‫So I'm going to challenge you to create a new C++ class, create a class based on --, and name this

68
00:04:59,490 --> 00:05:01,230
‫new class based --.

69
00:05:01,230 --> 00:05:03,600
‫Now you can leave all settings as is.

70
00:05:03,670 --> 00:05:05,200
‫In the class creation wizard.

71
00:05:05,200 --> 00:05:10,570
‫You don't need to change the file path or anything like that, so pause the video and create your first

72
00:05:10,570 --> 00:05:13,030
‫C++ class for this project.

73
00:05:16,320 --> 00:05:18,090
‫So back here in the level.

74
00:05:18,120 --> 00:05:21,690
‫So let's go up to tools and create new C++ class.

75
00:05:21,690 --> 00:05:24,260
‫I have not created the C++ class yet.

76
00:05:24,270 --> 00:05:27,180
‫I just closed out of this to go back to that slide.

77
00:05:27,180 --> 00:05:33,480
‫But now that I'm back, I'm ready to create my first C++ class for this project and I'm going to choose

78
00:05:33,480 --> 00:05:36,720
‫-- and you'll see that every time you hover over these.

79
00:05:36,720 --> 00:05:38,370
‫You've probably seen this before.

80
00:05:38,400 --> 00:05:44,790
‫We get a tooltip that pops up and it says, -- is the base class of all actors that can be possessed

81
00:05:44,790 --> 00:05:45,660
‫by players.

82
00:05:45,660 --> 00:05:52,680
‫Or I know that sounds pretty exciting, but we are going to configure this to be movable by input from

83
00:05:52,680 --> 00:05:53,370
‫a player.

84
00:05:53,370 --> 00:05:55,380
‫So this is perfect.

85
00:05:55,470 --> 00:06:01,020
‫It goes on to say that they are the physical representations of players and creatures in a level.

86
00:06:01,020 --> 00:06:07,080
‫So in other words, once we create this tank, it's going to represent us as players in the world.

87
00:06:07,080 --> 00:06:07,950
‫Pretty cool.

88
00:06:08,040 --> 00:06:15,960
‫So select -- and click next and it's showing us the path where it's going to stick this class in our

89
00:06:15,960 --> 00:06:20,070
‫project and you'll see that it's in source slash tune tanks.

90
00:06:20,070 --> 00:06:26,280
‫Now we're going to want to name our new -- because my -- is a horrendous name and it's very vague.

91
00:06:26,280 --> 00:06:29,700
‫We need something a little bit more specific now.

92
00:06:29,700 --> 00:06:35,400
‫We're going to plan on using this as a base class, meaning we're going to derive classes from this

93
00:06:35,400 --> 00:06:38,340
‫class so we can call this base --.

94
00:06:38,340 --> 00:06:43,080
‫Now, I know that's not much better than my --, but hey, it's telling us that this is a base --.

95
00:06:43,080 --> 00:06:46,770
‫This is something we're going to derive child classes from in the future.

96
00:06:46,770 --> 00:06:47,730
‫We'll get to that.

97
00:06:47,730 --> 00:06:52,320
‫But for now, we're going to call this base -- and we're going to click Create Class.

98
00:06:53,930 --> 00:06:54,590
‫All right.

99
00:06:54,590 --> 00:06:58,340
‫So Visual Studio code has opened up for us with our new class.

100
00:06:58,340 --> 00:07:01,700
‫We have based upon H and based upon CP.

101
00:07:01,730 --> 00:07:08,180
‫Now we can close this sidebar by clicking the Explorer icon there, and we can take a look at what V's

102
00:07:08,180 --> 00:07:09,890
‫code has generated for us.

103
00:07:09,890 --> 00:07:16,880
‫So by default we get the class constructor as well as three functions begin, play, tick and set up

104
00:07:16,880 --> 00:07:18,380
‫player input component.

105
00:07:18,410 --> 00:07:21,980
‫Now you should be familiar with Begin, Play and tick the comments here.

106
00:07:21,980 --> 00:07:23,300
‫Explain what they do.

107
00:07:23,330 --> 00:07:28,790
‫Set up player input component is something that the pawn gets and this function allows us to handle

108
00:07:28,790 --> 00:07:34,250
‫input such as from a keyboard key or a mouse click and we'll learn more about how this works in future

109
00:07:34,250 --> 00:07:35,690
‫videos in baseband.

110
00:07:35,840 --> 00:07:41,930
‫CP These functions are defined for us, but they're pretty bare and won't change that in future videos

111
00:07:41,930 --> 00:07:42,740
‫as well.

112
00:07:42,740 --> 00:07:49,370
‫So in this video we created our first C++ class and the next video will discuss components and why we

113
00:07:49,370 --> 00:07:51,770
‫would like to add some to our new class.

114
00:07:51,800 --> 00:07:52,790
‫I'll see you soon.

