First chapter of the lecture Unreal Engine Basics taught at SAE Institute Hamburg.
- Getting familiar with Unreal Engine as a technology, framework and toolset
- Learning the basics about writing Unreal Engine C++ code
5. First Things First
• At slideshare.net/npruehs you’ll always find these slides
• At github.com/npruehs you’ll find the source code of this module
• Ask your questions – any time!
• Each lecture will close with
▪ Further reading
▪ An optional assignment
• Contact me any time npruehs@outlook.com
6. Objectives
• Getting familiar with Unreal Engine as a technology, framework and
toolset
• Learning the basics about writing Unreal Engine C++ code
7. What is Unreal Engine?
• State-of-the-art 4th generation industry-leading game engine
• Created by highly skilled developers at Epic Games since 1995
• Huge community
• Completely open-source* and public roadmap
• Immense code base
* except for console platform integration (NDA)
8. What is Unreal Engine?
• Mature asset pipeline and editor
• Powerful animation and motion systems
• Highly performant renderer
• Engine and editor support for visual effects, AI, UI, audio, and more
• Engine-level multiplayer
• Visual scripting
• Desktop, console, mobile, web, TV, XR, streaming platforms
• Configuration, debugging, profiling, test automation
9.
10. UObjects
• Base class for all objects (similar to Java, C#)
• Garbage collection
▪ Don’t worry about memory allocation and deallocation – too much
• Reflection
▪ In C++. It’s black magic.
• Serialization
▪ Reading and writing property values for data objects and levels
• Editor integration
▪ Expose properties and functions to editor windows
11.
12.
13. Actor
• Any object that can be placed in a level
▪ Almost everything in Unreal is an actor
• Translation, rotation, and scale
• Can be spawned (created) and destroyed through gameplay code
• Ticked (updated) by the engine
▪ If you want it to
• Replicates to clients or server
▪ If you want it to
14.
15.
16. Actor Components
• Can be attached to actors to provide additional functionality
• Can tick and replicate as well
• Allow for a very clean, modular gameplay setup through re-usable
components
▪ Basic units in A Year Of Rain had 40 (!) components attached, e.g.
Abilities, Orders, Health, Attack, Name, Cost, Vision, Containable,
DestructionEffects, SpawnAudio, Footprints, MinimapIcon, …
17.
18.
19.
20. Game Mode
• Gameplay rules, e.g.
▪ Which GameState, PlayerController, PlayerState, Pawn to use
▪ Game initialization
▪ Player initialization
▪ Teams
▪ Victory & defeat conditions
• As an Actor, can tick as well
• Server only
21.
22.
23. Game State
• Global data relevant for all players, e.g.
▪ Match duration
▪ Score
• Server & client
24.
25.
26. Pawn
• Base class of all Actors that can be controlled by players or AI
• Physical representation of a player or AI within the world
▪ Location
▪ Visuals
▪ Collision
27.
28.
29. Character
• Special type of Pawn that has the ability to walk around
▪ SkeletalMeshComponent for animations
▪ CapsuleComponent for collision
▪ CharacterMovementComponent for movement
• Can walk, run, jump, fly, and swim
▪ Yes, swim.
▪ Did I mention that the engine has been used for 25 years already?
• Default implementations of networking and input
30.
31.
32.
33.
34. Controller
• Non-physical Actors that can possess a Pawn to control its actions
• One-to-one relationship between Controllers and Pawns
▪ PlayerController handles input by human players to control Pawns
o Create and update UI
o Authorative on (“owned by”) clients
▪ AIController implements the AI for the Pawns they control
o Setup and update behavior trees and blackboards
o Server only
38. What’s with all those prefixes?
UnrealHeaderTool requires the correct prefixes, so it's important to provide
them.
▪ Classes that inherit from UObject are prefixed by U.
▪ Classes that inherit from AActor are prefixed by A.
▪ Enums are prefixed by E (e.g. ENetRole).
▪ Template classes are prefixed by T (e.g. TArray).
▪ Classes that inherit from SWidget are prefixed by S.
▪ Classes that are abstract interfaces are prefixed by I.
▪ Most other classes are prefixed by F.
39. Project Layout
• Binaries. Compiled editor and game binaries.
• Config. Editor and game configuration files.
• Content. All (created and imported) game content (e.g. meshes, maps).
• Intermediate. Intermediate compiler output.
• Saved. Log files and local configuration.
• Source. Game and editor source code.
• .sln. Visual Studio solution file.
• .uproject. Unreal Engine project file.
40. Coding Standard
• You’ll read much more code than you write
▪ Most of the time, not even your own code
• Code conventions allow you to understand new code more quickly
▪ File layout
▪ Naming conventions
▪ Formatting & indentation
▪ Language features
• Cross-platform compatibility
https://docs.unrealengine.com/en-
US/Programming/Development/CodingStandard/index.html
41. C++ Codebase
By convention, put
▪ Header files in a Classes subfolder
▪ Source files in a Private subfolder
This allows for easier #include‘ing from other sources and modules.
I recommend creating C++ subclasses for the engine core game
framework first, as you‘re going to need them anyway.
42. Hint!
After moving or renaming files in your file system,
you can always regenerate your Visual Studio solution
from the context menu of your .uproject file.
43. Hint!
After moving or renaming files in your file system,
you can always regenerate your Visual Studio solution
from the context menu of your .uproject file.
You should also do so after updating from source control,
To make sure not to miss any new files.
44. Hint!
Because of how the UnrealHeaderTool works,
C++ namespace are (mostly) unsupported by Unreal Engine.
45. Hint!
Because of how the UnrealHeaderTool works,
C++ namespace are (mostly) unsupported by Unreal Engine.
By convention, you can append a shorthand of your
project name as prefix for your class names
to avoid naming collisions with existing classes.
46. Unreal Header File Layout
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/GameModeBase.h"
#include "ASGameMode.generated.h"
UCLASS()
class AWESOMESHOOTER_API AASGameMode : public AGameModeBase
{
GENERATED_BODY()
};
47. #include Statement Order
1. Pre-compiled header of the module
2. Arbitrary headers – but I recommend:
1. Base class header
2. Other engine headers
3. Other module headers
3. Generated header
48. Unreal Engine 4 Macros
• UCLASS indicates the type should be reflected for Unreal’s type system
• AWESOMESHOOTER_API exports the type for other modules (similar to
DLL_EXPORT)
• GENERATED_BODY injects additional functions and typedefs into the
class body
49. Assignment #1 – Setup Development Environment
• Install Visual Studio 2017 with Game Development With C++
• Download the Epic Games Launcher from
https://www.unrealengine.com/en-US/get-now
• Install Unreal Engine 4.23.1, including
▪ Starter Content
▪ Engine Source
▪ Editor symbols for debugging
50. Assignment #1 – Setup Project
• Create a new C++ Basic Code project with starter content
• Create C++ subclasses for the engine core game framework
▪ Character
▪ Game Mode
▪ Game State
▪ Player Controller
▪ Player State
51. References
• Epic Games. Reflections Real-Time Ray Tracing Demo | Project Spotlight | Unreal
Engine. https://www.youtube.com/watch?v=J3ue35ago3Y, March 21, 2018.
• Epic Games. Unreal Engine Features. https://www.unrealengine.com/en-
US/features, February 2020.
• Epic Games. Unreal Engine Gameplay Guide. https://docs.unrealengine.com/en-
US/Gameplay/index.html, February 2020
• Epic Games. Unreal Engine Programming Guide.
https://docs.unrealengine.com/en-US/Programming/index.html, February 2020.
• Epic Games. Unreal Property System (Reflection).
https://www.unrealengine.com/en-US/blog/unreal-property-system-reflection,
February 2020.
52. See you next time!
https://www.slideshare.net/npruehs
https://github.com/npruehs/teaching-
unreal-engine/releases/tag/assignment01
npruehs@outlook.com
53. 5 Minute Review Session
• What is the base class of all Unreal Engine objects?
• What type of object is put in Uneal Engine levels?
• Which part of the game framework is responsible of your game rules?
• What are GameState and PlayerState classes mainly used for?
• How does Unreal Engine abstract Pawns from how they decide to
move?
• Which parts of your header files are essential for the
UnrealHeaderTool and type system to work?