This is a short article with a few tips on how I hunt down engine code in UE4. There’s no big secret here, just a series of tools that can be combined by anyone with a little motivation.
The UE4 docs have a ton of great info, but as a C++ developer I find that the default search is mostly unhelpful. I find it most useful to filter by either Documentation or API.
You’ll often come across some blueprint node that you might want to see the code for. For many blueprints you can right-click and select to see the code, this will open Visual Studio directly to the code of interest for you to inspect.
Sometimes you’ll want to find code that touches a specific blueprint property. For instance, what the heck does this do? And more importantly how would we go about finding the relevant code?
First you need to find the variable name for the property. In many cases, you might not even know which class the property belongs to, all you’ll have to go off is the property description in the editor. This is when I like to turn to github search. Github search is indexed and lightning fast (unlike searching through VS).
Set a bookmark for the UE4 github repo now, you’ll use it all the time. There are 3 caveats to github search that you should be aware of first:
Now let’s run through how we’d track down Actor Hidden in Game.
Probably the most lucrative way to search is to first see if the code author added any extra comments to this property, this will get you a more unique string to search for. To do this, hover over the property and see what pops up.
Cha-ching! Be sure to surround the search with double quotes.
Well well, only a single result. Click on the line number to zoom in to the area of interest.
Now that you know the variable belongs to actor.h and is named
bHidden you can dig deeper.
At this point we’re done with github search. The problem with continuing the search on github is that it’s pretty dumb. For instance if 9 other classes have a variable named
bHidden it’s going to show you all of those matches and it’s going to be hard for you to sort them out. So don’t believe everything you see without using a better tool that has the context, like Visual Assist.
To continue, I like to open up Visual Studio solution explorer and drill down to the file.
I then highlight the variable and use Visual Assist to find all references of the variable.
Boom! There are a ton of results, so it depends what we’re interested in here. Do we want to know how HUD uses the flag, or if HeightFog uses it or maybe just how Actors themselves might use it? In this case let’s see how the Actor code uses the flag. It looks pretty simple, there are only 2 lines where the flag is used. Let’s check them out.
Bam! Now you can set a breakpoint etc.
If you haven’t used Visual Assist I have to say I felt it was worth the $100 for the personal license. It really helped me keep my sanity with the UE4 codebase.
Finally the last resource I use often is the Unreal Tournament github repo. There aren’t any other open source UE4-based games out there that are made by professionals. The UT repo is a gold-mine waiting to be harvested. Not sure how to use a function? Search for it. Want to see how a large project handles their UDamage heirarchy? Take a peak! Bored and want to learn something new? You don’t have to look far.