﻿1
00:00:04,550 --> 00:00:05,930
‫Hello and welcome.

2
00:00:05,930 --> 00:00:12,650
‫In this video, we're going to be creating our first C++ class and re compiling the editor from Visual

3
00:00:12,650 --> 00:00:13,430
‫Studio code.

4
00:00:13,430 --> 00:00:19,520
‫So at the end of the day, you will have a C++ class that you can locate in your content draw and a

5
00:00:19,520 --> 00:00:23,510
‫Visual Studio code project that you can open and compile.

6
00:00:23,510 --> 00:00:25,220
‫Let's dive in and see how.

7
00:00:25,930 --> 00:00:33,130
‫So now that we have all of our tooling in place, it's time to start creating some C++ classes.

8
00:00:33,250 --> 00:00:40,630
‫Now, before we do that, we need to switch our default editor so that we can use Visual Studio code

9
00:00:40,630 --> 00:00:41,590
‫by default.

10
00:00:41,620 --> 00:00:47,110
‫Now, the place to do this is in the editor preferences rather than in the project preferences.

11
00:00:47,110 --> 00:00:50,650
‫So it is a global setting across your entire editor.

12
00:00:50,770 --> 00:00:56,740
‫So we go to the edit menu, down to editor preferences and that pops up this tab here.

13
00:00:56,740 --> 00:01:03,370
‫And then we're going to look in the left hand pane at general and then source code and under there there's

14
00:01:03,370 --> 00:01:06,460
‫basically one option which is our source code editor.

15
00:01:06,490 --> 00:01:14,190
‫Now on a PC, this will default to Visual Studio 2022 on a mac, it will default to Xcode.

16
00:01:14,200 --> 00:01:19,480
‫We want to go ahead and change this setting so that we're all on the same page and using Visual Studio

17
00:01:19,480 --> 00:01:20,140
‫code.

18
00:01:20,170 --> 00:01:25,090
‫When you do that, a little pop up shows up saying, Hey, this setting requires that you restart the

19
00:01:25,090 --> 00:01:28,210
‫editor, so let's go ahead and restart it now.

20
00:01:28,360 --> 00:01:34,300
‫And I do encourage you to go ahead and do this and follow along with me and restart the editor while

21
00:01:34,300 --> 00:01:37,420
‫you're watching the rest of the next steps.

22
00:01:37,510 --> 00:01:41,420
‫So now we don't need our Editor preferences tab so we can close that down.

23
00:01:41,440 --> 00:01:44,440
‫What we want to do is create our first class.

24
00:01:44,440 --> 00:01:49,510
‫Now the class we're going to create is going to be for a moving platform that we're going to program

25
00:01:49,510 --> 00:01:50,800
‫in C++.

26
00:01:51,370 --> 00:01:59,560
‫So the place that we go to create a new C++ class is to the tools menu and then new C++ class here.

27
00:01:59,560 --> 00:02:05,500
‫So we click on that, brings up a new class wizard and this is going to automatically create some of

28
00:02:05,500 --> 00:02:07,940
‫the code for us to get us started.

29
00:02:07,960 --> 00:02:14,380
‫Now we want to create an actor because we're going to be placing this in the world as a moving platform.

30
00:02:14,380 --> 00:02:19,090
‫There's a few different options we could have, theoretically, but for simplicity's sake, we're going

31
00:02:19,090 --> 00:02:21,210
‫to start off with creating an actor.

32
00:02:21,220 --> 00:02:25,240
‫Then we can click on the next button and we want to give our actor a name.

33
00:02:25,240 --> 00:02:29,140
‫So my actor is a really rubbish name for this.

34
00:02:29,140 --> 00:02:35,650
‫We are going to be calling it Moving Platform and I'm going to type it like this with a capital M moving

35
00:02:35,800 --> 00:02:43,930
‫and then a capital P for platform and that because there's no spaces allowed in the names of classes

36
00:02:43,930 --> 00:02:45,070
‫in C++.

37
00:02:45,100 --> 00:02:51,760
‫This simply allows us to easily pick out the different words by using a capital letter to start each

38
00:02:51,760 --> 00:02:55,480
‫word, so you can easily see that it's moving platforms and not anything else.

39
00:02:55,690 --> 00:02:58,780
‫Then we can leave it in the default location.

40
00:02:58,780 --> 00:03:03,190
‫We can leave everything else as a default and just click create class.

41
00:03:03,220 --> 00:03:10,930
‫This is going to go through the process of generating all of the code and set up we need for C++ because

42
00:03:10,930 --> 00:03:17,800
‫up till now this project has simply been a blueprint only project, but now it's gone ahead and added

43
00:03:17,800 --> 00:03:21,490
‫all the things it needs to be a C++ and Blueprint project.

44
00:03:21,910 --> 00:03:26,620
‫You can see that there's this message will pop up that says your project now includes sources.

45
00:03:26,620 --> 00:03:29,160
‫Please close the editor and build from your ID.

46
00:03:29,290 --> 00:03:30,480
‫What is an ID?

47
00:03:30,490 --> 00:03:36,490
‫Well, ID stands for Integrated Development Environment, and for all intents and purposes, that just

48
00:03:36,490 --> 00:03:38,440
‫means our source code editor.

49
00:03:38,440 --> 00:03:45,460
‫So what it means is we want to open up the C++ in Visual Studio code, so we click okay to that.

50
00:03:45,460 --> 00:03:51,130
‫And then the next thing that pops up here is saying successfully added moving platforms, but you must

51
00:03:51,130 --> 00:03:52,030
‫recompile.

52
00:03:52,030 --> 00:03:54,220
‫Would you like to open the code editor now?

53
00:03:54,220 --> 00:03:58,420
‫Well, you should say yes, but I'm just going to show you what happens if you accidentally closed this

54
00:03:58,420 --> 00:03:59,830
‫message down by mistake.

55
00:03:59,830 --> 00:04:01,180
‫So we're just going to say no.

56
00:04:01,210 --> 00:04:06,160
‫It leaves us here in the editor and you'll notice if you go to a content browser, it hasn't added any

57
00:04:06,160 --> 00:04:07,930
‫C++ in here yet.

58
00:04:07,930 --> 00:04:10,990
‫And we'll see what that looks like in just a second.

59
00:04:10,990 --> 00:04:18,190
‫But what you can do if you forgot or didn't open the editor at that point is you can go back to your

60
00:04:18,190 --> 00:04:20,920
‫tools menu and click here.

61
00:04:20,920 --> 00:04:24,160
‫There is an open Visual Studio code option.

62
00:04:24,160 --> 00:04:29,740
‫Now, it's important to note that in recent versions we also have to click the Refresh Visual Studio

63
00:04:29,740 --> 00:04:31,880
‫Code Project every time we add a new class.

64
00:04:31,880 --> 00:04:36,940
‫This doesn't happen automatically for us at the moment, and then you can go on to click the open Visual

65
00:04:36,940 --> 00:04:39,460
‫Studio Code Project button after that.

66
00:04:39,460 --> 00:04:46,360
‫And if you didn't have this option here either or you had closed the editor or whatever, you can also

67
00:04:46,360 --> 00:04:55,150
‫go to your project in Windows Explorer or Finder and you can find the DOT code workspace file.

68
00:04:55,150 --> 00:05:00,760
‫That is the one that you can open and that will go ahead and open with Visual Studio code.

69
00:05:00,760 --> 00:05:03,460
‫Or you may need to choose to open it in Visual Studio code.

70
00:05:03,520 --> 00:05:05,890
‫And then this is what you'll end up with.

71
00:05:05,890 --> 00:05:10,000
‫You can see we have got by default, this terminal will not be open for you.

72
00:05:10,000 --> 00:05:11,440
‫So let's just close that down.

73
00:05:11,770 --> 00:05:16,660
‫And what you will see is there will be two tabs available here, potentially two tabs.

74
00:05:16,660 --> 00:05:22,060
‫They may not be open for you, but you'll have a explorer on the left showing you all the files in your

75
00:05:22,060 --> 00:05:22,600
‫project.

76
00:05:22,600 --> 00:05:25,180
‫You'll have maybe some code open in the center.

77
00:05:25,470 --> 00:05:26,490
‫Doesn't matter at this stage.

78
00:05:26,490 --> 00:05:30,210
‫We will get to understanding Visual Studio code a lot more later on.

79
00:05:30,240 --> 00:05:36,150
‫The main thing we want to use it for right now is to recompile our editor binary.

80
00:05:36,150 --> 00:05:39,420
‫So to do that, let's first close down our editor.

81
00:05:39,420 --> 00:05:44,760
‫It doesn't actually have to be closed to do this, but we might as well close it now and then we need

82
00:05:44,760 --> 00:05:52,080
‫to go to the terminal menu up at the top for Visual Studio code, then go down to run, build task.

83
00:05:52,080 --> 00:05:55,470
‫And you can see that there is an associated shortcut which will be using later on.

84
00:05:55,470 --> 00:05:57,620
‫So make note of what this is on your platform.

85
00:05:57,630 --> 00:06:02,880
‫For me, it's control shift B, so we're going to click that option and then what you want to do, you

86
00:06:02,880 --> 00:06:07,980
‫can see I've got a recently used task in here, but you will not have a recently used task.

87
00:06:07,980 --> 00:06:13,380
‫You'll need to scroll on down to find that task, which for me isn't in the options.

88
00:06:13,380 --> 00:06:20,940
‫But the important thing to look for is that it says editor, so we've got obstacle assault editor then

89
00:06:20,940 --> 00:06:23,310
‫development over here and then build.

90
00:06:23,310 --> 00:06:25,860
‫So we want editor development build.

91
00:06:25,860 --> 00:06:29,040
‫Let's go ahead and select the option that matches that for you.

92
00:06:29,040 --> 00:06:30,780
‫The platforms may be different.

93
00:06:30,780 --> 00:06:33,300
‫You can see that there is an iOS platform here.

94
00:06:33,300 --> 00:06:35,190
‫There is a win 64 platform.

95
00:06:35,190 --> 00:06:36,780
‫They'll probably be Mac platform.

96
00:06:36,780 --> 00:06:39,930
‫If you're on a mac, you're obviously going to go for the platform that you're on.

97
00:06:39,930 --> 00:06:43,770
‫I'm on Win 64, Windows 64, so that's the one I'm going for.

98
00:06:43,770 --> 00:06:45,630
‫So go ahead and click that.

99
00:06:45,900 --> 00:06:51,600
‫And what we'll do is we'll open a little window down here at the bottom called terminal and it will

100
00:06:51,600 --> 00:06:56,580
‫have a bunch of text scrolling by, which is the process of.

101
00:06:57,220 --> 00:07:03,190
‫Compiling this newly added C++ into binary that can be run in our editor.

102
00:07:03,310 --> 00:07:06,610
‫So this is a reasonably longer process.

103
00:07:06,610 --> 00:07:10,540
‫So I would like you to go ahead and get started compiling your own C++.

104
00:07:10,540 --> 00:07:15,220
‫So create a new moving platform, C++ actor in the editor.

105
00:07:15,220 --> 00:07:22,330
‫Remember to switch over from Visual Studio or Xcode to Visual Studio Code in the editor preferences.

106
00:07:22,630 --> 00:07:24,640
‫Open up Visual Studio Code.

107
00:07:24,640 --> 00:07:30,100
‫I've shown you a number of ways that you can open up the Visual Studio Code project, then compile the

108
00:07:30,100 --> 00:07:35,260
‫editor again using that run build task and have a look at the terminal.

109
00:07:35,260 --> 00:07:38,350
‫And when that's finished, you're going to relaunch the project.

110
00:07:38,350 --> 00:07:39,760
‫How do you know that it's finished?

111
00:07:39,760 --> 00:07:43,870
‫Well, at the end it will say terminal will be reused by tasks.

112
00:07:43,870 --> 00:07:45,280
‫Press any key to close it.

113
00:07:45,310 --> 00:07:50,410
‫It also shows you the total execution time for the build process.

114
00:07:50,410 --> 00:07:52,390
‫So that's how you know it will be finished.

115
00:07:52,390 --> 00:07:55,030
‫So pause the video and get to that point.

116
00:07:58,380 --> 00:07:59,010
‫Okay.

117
00:07:59,010 --> 00:07:59,850
‫Welcome back.

118
00:07:59,850 --> 00:08:02,520
‫So you can go ahead and relaunch the editor.

119
00:08:02,520 --> 00:08:07,290
‫At this point, you can either do it from Epic Games Launcher or by double clicking on the you project

120
00:08:07,290 --> 00:08:09,480
‫in your project folder.

121
00:08:09,630 --> 00:08:15,300
‫And when the project has opened up, you can go to the content drawer and now you'll see that next to

122
00:08:15,300 --> 00:08:16,650
‫your content folder.

123
00:08:16,650 --> 00:08:21,180
‫In the left hand pane you now have a C++ classes folder.

124
00:08:21,600 --> 00:08:28,110
‫If you click into that and go into the obstacle assault folder, you can see our moving platform class.

125
00:08:28,110 --> 00:08:33,180
‫So this being an actor can just be dragged right into our level.

126
00:08:33,240 --> 00:08:40,050
‫Now at the moment the actor is completely empty so it doesn't even have a position and location.

127
00:08:40,050 --> 00:08:46,680
‫So by default you will see the gizmo in the viewport being at the center of the map at 000.

128
00:08:46,680 --> 00:08:49,350
‫This is fine for now and we'll correct this later on.

129
00:08:49,350 --> 00:08:50,730
‫So go ahead and do that.

130
00:08:50,730 --> 00:08:56,280
‫Check that everything is working like that and save your map and I'll see you in the next video.

