Interface (C++)
An interface defines a contract — a set of functions that a class promises to implement, without dictating how. Think of it as a label: “this object can do X.” The caller doesn’t need to know the object’s actual type, just that it supports the interface.
In standard C++, interfaces are abstract classes with pure virtual functions. Unreal adds its own layer — UINTERFACE — which makes interfaces visible to the reflection system and to Blueprints.
A UE5 interface looks like this:
UINTERFACE()
class UMyInterface : public UInterface { GENERATED_BODY() };
class IMyInterface
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintNativeEvent)
void DoSomething();
};Any actor that implements IMyInterface can be called via IMyInterface::Execute_DoSomething(Actor). The caller doesn’t care if it’s a projectile, a grenade, or a door — it just calls the interface.
The key benefit: your systems stay decoupled. The pool subsystem doesn’t need to know about every actor type. It just asks “do you implement this interface?” and calls the function if so.
Further Reading
- Unreal Engine Documentation — Interfaces (docs.unrealengine.com)
- Bjarne Stroustrup, The C++ Programming Language — covers abstract classes and virtual functions