Class

Introduction Unreal Engine 4 is based around several paradigms, one at the core is Object Orientation. This describes Classes and Objects as basic building blocks, especially in relation to the C++...

Updated over 4 years ago

Introduction

Unreal Engine 4 is based around several paradigms, one at the core is Object Orientation. This describes Classes and Objects as basic building blocks, especially in relation to the C++ programming language which the Unreal Engine is built ontop of as its foundation.

Inheritance

In class based programming (a style of OOP) inheritance occurs through defining classes of the objects you intend to use.

class UYourObject : public UObject

Property Systems

An object can be a variable, a data structure, a function, or a method, which is why all types in the Property System start with the U prefix.

set to change in UE4.25

Object Instances

Object in this case refers to a particular instance of a class that is created.

UStaticMeshComponent* Mesh = NewObject (Owner);

In this example we can see the a new object Mesh is created from the class UStaticMeshComponent

Blueprint

Blueprint is used to create classes from within Unreal Editor, these are also Asset Types and it may also refer to the Graph Editor.

Defining Classes

As you can see from the below, all Objects defined UCLASS() require the GENERATED_BODY() macro so that property system can properly manage them.

Objects

Prefix for any Object in Unreal Engine 4 is U.

YourObject.h

UCLASS()
class UYourObject : public UObject
{
    GENERATED_BODY()
};

Actors

Prefix for any Actor in Unreal Engine 4 is A.

YourActor.h

UCLASS()
class AYourActor : public AActor
{
    GENERATED_BODY()
};

Class Literal

  • class
  • TSubclassOf
static ConstructorHelpers::FClassFinder PlayerPawnClassFinder(TEXT("/Game/Blueprints/MyCharacter"));
DefaultPawnClass = PlayerPawnClassFinder.Class;

Object Literal

Constructor

A special type of member function which is called when we instantiate an Object (or Actor) of this Class.

AYourClass::AYourClass()
{
    /* Your Actors Constructor - Not to be confused with Construction Script in Blueprint */
}

Destructor

Static Classes

Further Reading