TIL: Learn to Code in C++ by Developing Your First Game (Section 3, Lectures 53-56)

This involved a lot of getting my source control working… and I’m honestly not 100% confident in what I’ve done… the SourceTree solution that is being used in these videos seems more straight forward than Perforce, which is what I’ve decided to use out of habit. But as I’m not much for setting up pipelines, this could end up causing me a lot of headache.

Section: 3 – Building Escape – Your First Unreal / C++ Game

Lecture 53: Your First .gitignore for Unreal

UE creates Visual Studio files for us. We can also re-generate these when necessary

If you delete your .db file, then things are going to break. If you need to regenerate the file, you can do so by right clicking on the uproject file in windows explorer, and simply “Generate Visual Studio Files”

You can double click on the .sln file to rebuild the .db file, and you can double click on the .uproject file to rebuild the ue content. This is all just to say that you’re not completely screwed if you lose certain files. Others on the other hand are devastating to lose, which is why we want to back them up in a repository.

Now while Ben is using git repositories… I’m going to be using Perforce.. so I need a depot and a Workspace. The workspace is where I’m working from, and the depot is a folder where I back it up to.

I’ve done this in the past, and so not much is needed to continue working… I simply create my workspace, point it to my udemycplusplus folder which I’ve already started the project in, and then start adding files to the depot.

The problem is, if we just right click the top folder, and mark it to be added, we’ll end up committing 355 files in. We don’t need the Binaries, the Build, DerivedDataCache, Intermediate, or Saved folders though. We also don’t need the Content/StarterContent or our VC.db file. If we can exclude all that, we’ll only need to commit 13 files into our repository (depot for p4 users).

The set-up in perforce isn’t as simple as it is in SourceTree, but the functionality is certainly still there. You can use Ignore Lists in P4VS to specify files or filetypes that you want to keep in your project but do not want to add to the Perforce repository. An Ignore List is a file in your local workspace directory that contains a list of file names or file types to ignore. For example, you can create an Ignore List called .p4ignore in your project folder.

So in my case, I created a .p4ignore.txt file which I placed in my main directory. For reference, my overall perforce workspace directory has been set to D:\Perforce_Workspace\udemycplusplus\ as I’m assuming there will be a part 4, to this course and I’ll want to keep everything both in separate folders later, but unified under this single directory.

So inside this udemycplusplus folder, is where I put the 03_BuildingEscape folder and all of the resulting project files for this tutorial. Inside this uduemycplusplus folder is also where I have chosen to place my .p4ignore.txt file.

The contents of my ignore file then look like this:

# Unreal Generated Files #

# VS Generated Files #

Once the file has been saved, the next step is to set up a windows environment variable so that perforce knows what to search for in order to ignore files. In this case, you can press that windows button on the keyboard, and start typing “command prompt” open it up and type:

p4 set P4IGNORE=.p4ignore.txt

Now what happens, is when we right click and “add” our files in perforce, we’ll get a dialogue warning us that files are not marked for add since they are ignored.


We’ve now got perforce set-up to do version control on all of the items except for what we’ve told it to ignore. And sinceI’m also committing my .p4ignore.txt file, that means 14 files have been added. Great!

Lecture 54: Getting to Know Unreal’s Editor

This video basically just covers how to navigate in UE4. I’m only going to address things that are new to me.

One difference that I’m noticing, is that SourceTree appears to be working with Ben’s files even when Unreal Engine is not connected to source control. With Perforce, it won’t allow me to work so freely with the files… I have to actively connect the Source Control in UE4, set it to perforce, select my workspace, and then actively check files out when I want to work with them. After creating a new map for example, I have to check out the DefaultEngine.ini file in order to be able to set a default map.

I’ve emailed Ben for more info on why he isn’t using the UE Source Control options.


Ben’s response was: “Hi Stephen, the reason in that section was that I want to cover the fundamentals first. I plan to show the Unreal hook-up in the next section. Thanks for asking.”

Lecture 55: A Pointers Primer

I don’t remember what a pointer is! I think I remember them from when I was attempting to learn Unity C# a couple of years ago…
– The clue is when you see a * next to a type
– Pointers are simply memory addresses
– You have to “follow” the pointer to the object
– Benefit: saves you from moving things in memory
– Disadvantage: you can lose control of data

The below Pointer Syntaxes are all identical:
FActorComponentTickFunction* ThisTickFunction
FActorComponentTickFunction * ThisTickFunction
FActorComponentTickFunction *ThisTickFunction

The thing on the right, is a pointer of the type of the thing on the left.

In addition to the pointer, we have the -> Accessor Operator. Ben’s description confuses me, and googling accessor results in the first result being scary.

AActor* SomeActor;
AActor class has a method called GetName()
*SomeActor “de-references” the pointer
You could write (*SomeActor).GetName();
But you can also use -> to follow and access in one snippet of code.

more on pointers:

Lecture 56: Unreal’s Class System

OooooooOOOOoooo… we get to actually make some c++ that interacts with UE now! We also become familiar with Classes. The Class Viewer is documented here.

Inheritance is a type of relationship. Inheritance means that you inherit attributes from above.
-Character is a Pawn, Pawn is an Actor.
-Dog is a Mammal, Mammal is an Animal.

-UE makes extensive use of inheritance, which can be powerful, but can also be inflexible and difficult if not used correctly.

You can attach components onto objects, and this is more like a “has a” relationship.

Fuck. The Class Viewer is quite the instant intimidation. I had no concept there were this many different things in UE that I had no concept of.

– We add a chair to the level
– add a c++ component to the chair
– set it to actor component
– Name -> PositionReport
– Create Class

Supposedly this should have opened Visual Studio for me automatically… but it didn’t… I had to manually open it and search my solution for PositionReport. It also gave me the following error:


"Successfully added class 'PositionReport', however you must recompile the 'BuildingEscape' module before it will appear in the Content Browser. Failed to automatically compile the 'BuildingEscape' module.

Would you like to open the Output Log to see more details?"

I told Visual Studio to build my files, and then closed and re-opened UE and it worked fine. I’m not sure exactly what I should be doing to get this working… but I wouldn’t be surprised if there’s something flawed in my source control workflow…

It temporarily seems like it’s working…. but SourceTree seems to be doing some magic that allows you to edit files without checking them out… so… I’m weary about what this means for the workflow going forward. I might need to make some explicit connection between Visual Studio and perforce, or I might need to be explicit in opening both programs when I want to begin working.

Time for sleep.

2 thoughts on “TIL: Learn to Code in C++ by Developing Your First Game (Section 3, Lectures 53-56)”

  1. Varomix Wey says:

    About Git and Perforce, the way Git works, once you setup the repo git just detects ANY change in the file, no matter who changes the file, is has nothing to do with UE4 or Visual Studio, once the file changes on the system it marks it as modified and ready to commit.

    Now Perforce does exactly the same thing and on top of that gives you this exclusive ownership of the file, this is why you have to checkout the file, this means no one else can modify the file, the file gets locked in the SERVER, so the main server the code is in when you setup perforce.

    Both Git and Perforce are meant to work with text files, mainly code, once you modify a text file, Git finds the difference with the previous file and uses a patch system to just INSERT or REMOVE that text in the right place, in Git, several people can work on the same file at the same time and then git tries to merge all the changes into the same file, it also handles binary files but has no idea what to do with them so just pushes the whole file at once every time there’s a change.

    Now, been that Unreal uses a ton of binary files, converts everything to .uassets which Git just handles as one binary blob, that’s where perforce is useful when a team is working on an unreal project, been that perforce LOCKS the file, if you and I are working on that same project and you checkout the player, if I try to open it, perforce will tell me that Stephen is editing that file or something like that, that prevents errors or out of sync issues, again, being that .uassets are binaries.

    So, if you’re just working by yourself, I recommend just using Git, is simpler to setup and it just tracks everything without you having to do anything till you are ready to commit and push your changes.
    If you need to work with 2 or more people on a team, and they are all working inside UE4, then Perforce is a better option.

    If you have any questions let me know, I’ve dealt with this stuff before.
    Hope that helps 🙂

    1. Allegro says:

      Thanks for commenting!

      I set-up perforce because I’m planning on doing some game dev stuff soon and want to make sure that I understand it so that I can get other people working on it and scale up without too much additional work.

      I’ve already got the depot going to my OneDrive account, so it’s doing my back-ups to the cloud and so it should be fairly easy to get someone else into a project.

      It’s overkill for doing the tutorial I’m sure, but at the same time forcing myself to use Perforce will make it easier in that hypothetical future where I need to work with someone else.

      It does seem like it’s going to make things more awkward though since I’ll need to be worried about checking out files… but I guess it’s better to force myself into that workflow and iron out any kinks before I decide to get someone else involved in working with me 🙂

Comments are closed.