‫Hello and welcome.
‫In this video, we're going to be creating our first C++ class and re compiling the editor from Visual
‫Studio code.
‫So at the end of the day, you will have a C++ class that you can locate in your content draw and a
‫Visual Studio code project that you can open and compile.
‫Let's dive in and see how.
‫So now that we have all of our tooling in place, it's time to start creating some C++ classes.
‫Now, before we do that, we need to switch our default editor so that we can use Visual Studio code
‫by default.
‫Now, the place to do this is in the editor preferences rather than in the project preferences.
‫So it is a global setting across your entire editor.
‫So we go to the edit menu, down to editor preferences and that pops up this tab here.
‫And then we're going to look in the left hand pane at general and then source code and under there there's
‫basically one option which is our source code editor.
‫Now on a PC, this will default to Visual Studio 2022 on a mac, it will default to Xcode.
‫We want to go ahead and change this setting so that we're all on the same page and using Visual Studio
‫code.
‫When you do that, a little pop up shows up saying, Hey, this setting requires that you restart the
‫editor, so let's go ahead and restart it now.
‫And I do encourage you to go ahead and do this and follow along with me and restart the editor while
‫you're watching the rest of the next steps.
‫So now we don't need our Editor preferences tab so we can close that down.
‫What we want to do is create our first class.
‫Now the class we're going to create is going to be for a moving platform that we're going to program
‫in C++.
‫So the place that we go to create a new C++ class is to the tools menu and then new C++ class here.
‫So we click on that, brings up a new class wizard and this is going to automatically create some of
‫the code for us to get us started.
‫Now we want to create an actor because we're going to be placing this in the world as a moving platform.
‫There's a few different options we could have, theoretically, but for simplicity's sake, we're going
‫to start off with creating an actor.
‫Then we can click on the next button and we want to give our actor a name.
‫So my actor is a really rubbish name for this.
‫We are going to be calling it Moving Platform and I'm going to type it like this with a capital M moving
‫and then a capital P for platform and that because there's no spaces allowed in the names of classes
‫in C++.
‫This simply allows us to easily pick out the different words by using a capital letter to start each
‫word, so you can easily see that it's moving platforms and not anything else.
‫Then we can leave it in the default location.
‫We can leave everything else as a default and just click create class.
‫This is going to go through the process of generating all of the code and set up we need for C++ because
‫up till now this project has simply been a blueprint only project, but now it's gone ahead and added
‫all the things it needs to be a C++ and Blueprint project.
‫You can see that there's this message will pop up that says your project now includes sources.
‫Please close the editor and build from your ID.
‫What is an ID?
‫Well, ID stands for Integrated Development Environment, and for all intents and purposes, that just
‫means our source code editor.
‫So what it means is we want to open up the C++ in Visual Studio code, so we click okay to that.
‫And then the next thing that pops up here is saying successfully added moving platforms, but you must
‫recompile.
‫Would you like to open the code editor now?
‫Well, you should say yes, but I'm just going to show you what happens if you accidentally closed this
‫message down by mistake.
‫So we're just going to say no.
‫It leaves us here in the editor and you'll notice if you go to a content browser, it hasn't added any
‫C++ in here yet.
‫And we'll see what that looks like in just a second.
‫But what you can do if you forgot or didn't open the editor at that point is you can go back to your
‫tools menu and click here.
‫There is an open Visual Studio code option.
‫Now, it's important to note that in recent versions we also have to click the Refresh Visual Studio
‫Code Project every time we add a new class.
‫This doesn't happen automatically for us at the moment, and then you can go on to click the open Visual
‫Studio Code Project button after that.
‫And if you didn't have this option here either or you had closed the editor or whatever, you can also
‫go to your project in Windows Explorer or Finder and you can find the DOT code workspace file.
‫That is the one that you can open and that will go ahead and open with Visual Studio code.
‫Or you may need to choose to open it in Visual Studio code.
‫And then this is what you'll end up with.
‫You can see we have got by default, this terminal will not be open for you.
‫So let's just close that down.
‫And what you will see is there will be two tabs available here, potentially two tabs.
‫They may not be open for you, but you'll have a explorer on the left showing you all the files in your
‫project.
‫You'll have maybe some code open in the center.
‫Doesn't matter at this stage.
‫We will get to understanding Visual Studio code a lot more later on.
‫The main thing we want to use it for right now is to recompile our editor binary.
‫So to do that, let's first close down our editor.
‫It doesn't actually have to be closed to do this, but we might as well close it now and then we need
‫to go to the terminal menu up at the top for Visual Studio code, then go down to run, build task.
‫And you can see that there is an associated shortcut which will be using later on.
‫So make note of what this is on your platform.
‫For me, it's control shift B, so we're going to click that option and then what you want to do, you
‫can see I've got a recently used task in here, but you will not have a recently used task.
‫You'll need to scroll on down to find that task, which for me isn't in the options.
‫But the important thing to look for is that it says editor, so we've got obstacle assault editor then
‫development over here and then build.
‫So we want editor development build.
‫Let's go ahead and select the option that matches that for you.
‫The platforms may be different.
‫You can see that there is an iOS platform here.
‫There is a win 64 platform.
‫They'll probably be Mac platform.
‫If you're on a mac, you're obviously going to go for the platform that you're on.
‫I'm on Win 64, Windows 64, so that's the one I'm going for.
‫So go ahead and click that.
‫And what we'll do is we'll open a little window down here at the bottom called terminal and it will
‫have a bunch of text scrolling by, which is the process of.
‫Compiling this newly added C++ into binary that can be run in our editor.
‫So this is a reasonably longer process.
‫So I would like you to go ahead and get started compiling your own C++.
‫So create a new moving platform, C++ actor in the editor.
‫Remember to switch over from Visual Studio or Xcode to Visual Studio Code in the editor preferences.
‫Open up Visual Studio Code.
‫I've shown you a number of ways that you can open up the Visual Studio Code project, then compile the
‫editor again using that run build task and have a look at the terminal.
‫And when that's finished, you're going to relaunch the project.
‫How do you know that it's finished?
‫Well, at the end it will say terminal will be reused by tasks.
‫Press any key to close it.
‫It also shows you the total execution time for the build process.
‫So that's how you know it will be finished.
‫So pause the video and get to that point.
‫Okay.
‫Welcome back.
‫So you can go ahead and relaunch the editor.
‫At this point, you can either do it from Epic Games Launcher or by double clicking on the you project
‫in your project folder.
‫And when the project has opened up, you can go to the content drawer and now you'll see that next to
‫your content folder.
‫In the left hand pane you now have a C++ classes folder.
‫If you click into that and go into the obstacle assault folder, you can see our moving platform class.
‫So this being an actor can just be dragged right into our level.
‫Now at the moment the actor is completely empty so it doesn't even have a position and location.
‫So by default you will see the gizmo in the viewport being at the center of the map at 000.
‫This is fine for now and we'll correct this later on.
‫So go ahead and do that.
‫Check that everything is working like that and save your map and I'll see you in the next video.