So you’ve got Visual Studio installed. Great! I’m gonna start from there.
After you’ve got VS, you should find your project’s .uproject file, right click, and hit Generate Visual Studio Project Files. After that you’ll see that a .sln file was created in the same folder. This is you project’s “solution”. I recommend that you open this up, and let it parse all the unreal and project source codes. This will take a while, you’ll see what file is being parsed at the bottom of VS. When it says “Ready”, it means that it is done. Now you can either press F5 in VS to start the engine with VS attached (very good for debugging) or you can just open your project like you used to (from Epic Launcher, or by clicking on the .uproject file).
Creating a new C++ class
In your project nothing has really changed for now. So let’s say you want to create a new C++ class. In Unreal, at the top you’ll see File → New C++ class. Pick a parent class. After that you’ll see a window where you can decide the name, and where to put the file. Your project’s source code (the C++ files) will be outside of your project’s content folder. By default, the path will be correct so you don’t really have to change anything there. We usually split the project source code into “Public” and “Private” folders. C++ .h files go to public, C++ .cpp files go to the private folder. Unreal will automatically do this for you if you click the “Public” button on the right. (You may have to click “Private” first and then “Public”). Next step is to click on the green Create Class button. Unreal will start compiling. If you see an error message pop up, don’t worry! It happens a lot. Additionally, If you started the engine through VS, it will ask you if you want to reload the solution as well. You can hit “Yes to all” after you’ve closed the engine.
Solving initial errors
“So what to do if you got an error in Unreal when you created the class?”
Just close the engine, and press F5 again in VS.
"I pressed F5 but I get a compile error! I haven’t even coded anything yet!"
Usually this happens when you didn’t put the C++ file in the project’s root source folder. If this is the case, all you have to do is update the includes in the .cpp files. Let’s say you created MyCharacter class in Source/MyProjectName/Public/MyTestFolder/ so the default include path will be wrong.
// this is the default include path
// this is the fixed include path
“I created C++ classes already that I don’t need, how to delete them?”
Go to your project’s source folder, and delete the .h and .cpp files you don’t need. After that, find your .uproject file, right click, and hit Generate Visual Studio Project Files.
A bit of an overkill post, but I had a lot of issues with C++ project when I was starting out, so hopefully this clears some things up for you. Cheers!