Unreal C++

Learning "Unreal C++" might be much easier than you think. It's halfway to the simplicity of custom scripting language.

Updated about 1 year ago Edit Page Revisions

Extensive C++ API

People are often scared of learning C++ in Unreal Engine. It comes from the fact that pure C++ requires a lot of low-level knowledge, taking care of cleaning up memory, assembling build toolchain.

The thing is you don't use pure C++ with Unreal Engine, the same way you don't use pure C# with Unity. Thanks to that writing C++ code for Unreal Engine is much, much easier than regular C++. Actually, it's more similar to Unity's C#.

  • Epic built a multiplatform C++ library, tailored for game development. This is the engine's core. Something we often simply call "Unreal C++".

  • It provides low-level mechanisms (reflection, object handling with garbage collection) working under the hood. This works with everything that's is marked as U-thing: UCLASS, UFUNCTION, UPROPERTY. Every object in the world is based on the UObject class, which is automatically garbage collected. Check Basic Object Classes. This all brings the C++ environment closer to C# or scripting languages.

  • Unreal C++ provides its own libraries supporting math, vectors, strings (with support for text localization) and many other standard things. Just to make development easier, preventing game programmers from reinventing the wheel for every single game.

  • Writing code is simplified, thanks to dozens of built-in class, function and property specifiers. Also macros and many utilities. The effect is we got a fully functional game framework out of the box.

  • Multiplayer and replication are supported on the core engine level. Not something you would with standard C++ library.

  • Unreal's C++ API is commonly considered as "half-way to the simplicity of scripting languages" - in the perspective of full-time programmers. It's still C++, the entry barrier is higher than any scripting language or C#.

Setting yourself up

It's critical for your productivity to begin a journey into the land of Unreal C++ with proper tools. C++ is punishing those who try to approach with bare hands.

  • Use plugins like Resharper C++ with Visual Studio. It's not the fault of Unreal, Visual Studio tools don't handle C++ well. Especially large codebases like game engines. It's standard for a C++ programmer to not rely on Intellisense tool provided with Visual Studio. Read more on efficient Setting up Visual Studio for Unreal Engine.

  • For those looking for an even better tool than Visual Studio, Rider for Unreal Engine is coming. It's a cross-platform IDE, available on Windows, Mac and Linux. Preview only works on Windows but is already praised by many programmers. It offers functionality similar to VS with Resharper++ (as Resharper is built-in into Rider). There won't be a free version, however.

  • One of the most annoying things that remain in Unreal C++ is compiler/linker error messages which aren't very clear, especially for beginners. Using tools like Resharper++ helps tremendously, it does properly highlight a lot of simple issues. Still, if you stuck at something, try asking questions online. Communities like Unreal Source (formerly known as Unreal Slackers) are an amazing help. Just don't expect them to read your mind, explain your issue properly.

Be warned, Unreal C++ environment doesn't provide a perfect way to compile the project without ever closing the editor.

  • There's a mechanism called Hot Reload (triggered by a huge button in the editor toolbar) which allows rebuilding C++ code even if you changed code in the C++ header (.h file) or even added new classes. Unfortunately, it causes occasional data loss... UE 4.26 promises to fix the major issue UE-52220.

  • However, Epic integrated Live++ to all developers since 4.22 - it allows you to safely recompile changes in .cpp files. It's quick and 100% stable. Even if the game is running! Super sweet, although limited only to .cpp files. It won't work with changes made to .h files.

Learning curve for Unreal C++ is steep, partially because official docs don't explain programming/C++ concepts - assuming everybody is programmer already...

Make the most of it

In theory, you could live without things below - especially if you've got only a single programmer in the team. However, this is essential for efficient work.

  • Unreal ENgine source code is available publicly, free of charge. You can download source code and debugging symbols through Epic Games Launcher. Engine won't be a black box anymore, you can truly understand how it works. It's not unusual to copy-paste small portion of engine code, often to quickly set up your own editor tool.

  • Set up some kind of "build system" if having 2+ programmers - you need to compile C++ and then open editor, no magical compilation in the editor like in Unity. It's nothing difficult, it's great for non-programmers to obtain compiled binaries from the repository. And it makes easier to take advantage of the next sweet thing...

  • It's totally optional, but it's also common for Unreal teams. Ignoring pre-compiled engine available through the Epic Games Launcher and compiling engine from source. We call it a "source build". After that, you can easily alter small things in the engine - fix critical bugs, expose hidden things to the project, improve your tools and workflows.

Further read

Go ahead, check Introduction to Unreal C++ in official documentation :)

P.S. Epic purchased company behind SkookumScript for a reason. This a speculation, but they might come up with a custom scripting language designed to fill a gap between blueprints and C++. And that would serve us much better than just stitching another general-purpose language to the engine.