Unreal Engine Basics

Getting started with Unreal Engine 4 game development. Covering UE4 Macros (UProperty and UFunction), combining C++ with blueprints, base classes like Pawns and Actors, and understanding GameMode, GameState, PlayerController, PlayerState and much more.

Coding Standards and Naming Conventions

In this video we're going to dive into the naming conventions that are used within Unreal Engine source code. Using this UE4 naming standard will help us be able to quickly identify the types of classes and objects in our project. We have a handy c++ cheat sheet available at https://uecasts.com/resources/unreal-engine-c-plus-plus-cheat-sheet where you can find these prefix and naming tables. Lets dive in on the prefixes. Previously we covered how Pawn's and Actors are some of the base classes within Unreal Engine. Within UE4 all classes that inherit from an Actor will have a prefix of an `A` this will allow us to identify what classes are Actors while working in our codebase. Futher we see the other prefixes are pretty straight forward with Boolean as a `b`, Enums as `E`, Interfaces as an `I` and so on. One caveat is the `F` prefix for struct. The `F` prefix is a fun back story as shared by `Dark-Veil` who is an Unreal Engine programmer at Epic Games. In the UE forums he states that Tim Sweeney wrote the original `FVector` class which represented a floating point vector. This naming convention was used for other math constructs as the engine utilized floating point values extensively. To this day some classes still represent their original Unreal Engine 1 counterparts. Okay that was a fun tangent. Let's jump into the codebase and see how this gets used. In our First Person Character class we see we have our AUEFpsTestCharacter class. If we go to the header file for this class we see that it inherits from ACharacter class. Because we have the `A` we know this is an Actor. Next we go into ACharacter file and we see it also inherits from APawn which we know is an Actor. What we see is the Pawn is the base class of all actors that can be possessed by players or AI. They are the physical representations of players and creatures in a level. What we can also see is that APawn class inherits from AActor which is what propagates the Actor prefix up to our AUEFpsTestCharacter class. We also see Pawn inherits from INavAgentInterface. So we know that Pawn is both an Actor and implements the Navigation Agent Interface class methods. We also see a TArray which is a Template Array of FLifeTimeProperty objects. Within FLifeTimeProperty class we see it's job is to store an unsigned 16 bit integer for the RepIndex as well as the LifeTimeCondition and LifeTimeRepNotifiyCondition which are both Enums with the `E` prefix. Further down we see a UPROPERTY which is allowing this boolean variable bUseControllerRotationPitch to be modified anywhere as well as the ability to modify within blueprint with the BluePrintReadWrite property. Next we see a TEnumAsByte array with is a Template Enum array. The EAutoReceiveInput class is an enum class prefixed with `E`. Inside we can see it has 9 different enum types for automatically receiving input from a player. Outside of C++ naming conventions it's also common to name any blueprint classes with `BP_`. If we take our UEFpsTestCharacter C++ class and create a new blueprint from it we can prefix this with `BP_`. This allows us to know what classes within the editor are blueprints. In the top right of our new blueprint class we can see that it inherits from our base C++ character class. Which if we click on will take us back to our C++ code where we started. Utilizing these naming standards will make it easier for us and team members to know what type each class is at a quick glance. These standards help the entire team both veteran and newcomers understand the codebase in a shorter amount of time. In the next video we'll start coding our FPS game from scratch.