The Open Unreal Conventions are an open source set of coding and asset conventions for Unreal Engine 4 projects created and maintained by Jonas Reich.
These conventions should serve as a foundation for all aspects of Unreal Engine development. This means they cover not only C++ code, but also Blueprints, Python and Asset creation. Over time we might also add some conventions for complementary tools like batch scripts for building Unreal Engine games.
The coding conventions are a work-in-progress project. This list shows the current status of the sub-conventions:
domain | progress |
---|---|
Project Setup | 50% |
Assets | 90% |
Blueprint | 50% |
C++ | 90% |
Python | 100% |
You probably are not the only developer in a project. And even if you are you will most certainly come back to a piece of code, a blueprint or an asset folder that you haven't seen in a while. It is very likely that you will forget and re-learn half of the things you worked on over the course of a project.
Creating a structure that is easily parse-able for an uninformed viewer is crucial for project maintainability. And all other rules are based on this very thought.
This should usually manifest in thinking about the big picture first and structuring your content from big to small.
There is a rule in psychology stating humans cannot easily separate and memorize groups of more than seven objects (plus minus seven). We can apply this rule to our C++ code and Blueprints saying you should introduce logical groupings once you have more than 7-10 variables, functions, etc.
Of course this all depends on the context, but it's a good rule of thumb to recognize code, blueprints, etc that are too crowded.
For all logical programming no matter the language (Blueprints, C++, Python) you must always adhere to the following basic rules:
- Leave a file at least as clean as you found it
- Fix errors when you stumble across them
- Don't submit any broken code including code that you know throws errors or warnings
- Your code must always be clean, well formatted and properly documented
- You must always stick to SOLID principles and write DRY code
- Consistency is king. Stick to existing conventions and establish new ones as soon as you do something not covered by conventions.
- Never leave any dead/unreachable/commented-out code
Always use PascalCase. This applies for assets, folder names, variable names, function names, you name it.
- Already used by Engine code
- Already used by sample content
- Only exception: Python
Never use spaces for names. This is mainly important for asset and folder names (including the folders in which you store your unreal projet), but can also be extended to variables and functions in your Blueprints.
Stick to Latin Alphanumerics and underscores. Never use special unicode characters, umlauts or any other special characters. In short, stick to this set of characters:
ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789_
Keep names short and concise. Short and readable is the key here. Other devs still need to understand what you mean. Unreal enforces a 180 character path limit for all source files and assets, so keeping file and folder names short is essential. It also makes file lists, debug logs, etc easier to read. This last point also applies to function and variable names.
These coding conventions are based on a mixture of the following coding conventions:
- C++ Coding Conventions
- Epic Games Coding Standard
- Google C++ Style Guide
- C++ Core Guidelines
- Aesir Interactive Unreal C++ Coding Conventions (not public)
- Blueprint Coding Conventions
- Gamemakin UE4 Style Guide aka "Allar style guide"
The following sources are reccommended reading material for their respective topic:
-
General
-
Unreal Engine 4 Documentation - The official docs should be your first address for everything Unreal related. It used to be quite outdated with gaping holes, but since UE4.24 onwards the documentation has caught up with some of the latest developments of the Engine itself.
Still not everything is documented in here, but for everything that is, it's usually the best introduction into each respective topic if not the most comprehensive.
-
Unreal Engine 4 Source Code - The engine's source code is shipped with every UE4 installation, so whenever you want to know what's really going on under the hood, see examples how a certain system/function should be used, etc. this is the place to look.
The source code is really well documented (at least in the important places - some plugins could improve) and will often times contain better comments + explanations besides the code itself than the online documentation.
-
-
Multiplayer / Networking
- Network Compendium by Cedric 'eXi' Neukrichen - Good overview of everything network related. Explains both the high level networking architecture but also shows some low level code snippets that will cover 80% of your net-code needs.
-
Gameplay Ability System
- GASDocumentation by tranek - Very comprehensive breakdown of gameplay ability system with many practical examples, code snippets and reccommendations for different use cases (including performance optimization opportunities).
The Open Unreal Conventions are licensed under the MIT license.
You are invited to create pull-requests to the github source for any additions or modifications you make to the guidelines.