Works in Unreal Engine 5.0 to 5.8. Updated November 2026.
Quick answer: don’t convert your whole project. Move one piece:
- Tools > New C++ Class, pick Actor Component, name it
HealthComponent. - Add a variable with
UPROPERTY(EditAnywhere, BlueprintReadWrite)and a function withUFUNCTION(BlueprintCallable). - Compile, add the component to a Blueprint, and call the function from your graph like any other node.
C++ does the work, and your Blueprints keep doing what they’re good at.
Before you start: the UE6 question
Epic announced that UE6 will remove the C++ Gameplay Framework along with Blueprints, so rewriting your gameplay in C++ won’t carry it into UE6. Learn C++ because it helps you today: faster heavy logic, access to engine features Blueprints don’t expose, and plugin work. Engine-level work in UE6 stays C++, and typed code is a good step towards Verse. Details in our UE6 summary.
You need Visual Studio 2022 or Rider with the C++ game development workload installed.
Step 1: Create the class
- In the editor, open Tools > New C++ Class.
- Choose Actor Component and click Next.
- Name it
HealthComponentand click Create Class.
Unreal adds the files, converts a Blueprint-only project to a C++ one if needed, and compiles. The first build takes a few minutes.
Step 2: Write the header
Open HealthComponent.h. Add the variables and the function inside the class, below GENERATED_BODY():
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Health")
float MaxHealth = 100.f;
UPROPERTY(BlueprintReadOnly, Category = "Health")
float Health = 100.f;
UFUNCTION(BlueprintCallable, Category = "Health")
void TakeHit(float Amount);
UFUNCTION(BlueprintPure, Category = "Health")
bool IsDead() const { return Health <= 0.f; }
UPROPERTYmakes a variable show up in the Details panel and in Blueprints.UFUNCTION(BlueprintCallable)makes a node with an execution pin.BlueprintPuremakes a node without one, like a getter.
Step 3: Write the function
Open HealthComponent.cpp and add:
void UHealthComponent::TakeHit(float Amount)
{
Health = FMath::Clamp(Health - Amount, 0.f, MaxHealth);
}
In BeginPlay(), which the template already created, add Health = MaxHealth; so every actor starts full.
Step 4: Use it from Blueprints
- Compile from your IDE, or click the Live Coding button at the bottom right of the editor.
- Open your character Blueprint and click Add, then search for Health Component.
- Drag the component into the graph and call Take Hit and Is Dead, just like built-in nodes.
That’s the pattern most teams use: systems in C++, tuning and gameplay glue in Blueprints.
Blueprint nodes and their C++ versions
| Blueprint | C++ |
|---|---|
| Event BeginPlay | BeginPlay() |
| Event Tick | TickComponent() (or Tick() on an actor) |
| Branch | if (...) { } else { } |
| Print String | UE_LOG(LogTemp, Warning, TEXT("Hi")); |
| Delay | A timer: GetWorld()->GetTimerManager().SetTimer(...) |
| Cast To MyCharacter | Cast<AMyCharacter>(Actor) |
| Is Valid | IsValid(Object) |
| ForEach Loop | for (AActor* A : Actors) { } |
Common beginner problems
| Problem | Fix |
|---|---|
| The new node doesn’t show in Blueprints | Check the UFUNCTION(BlueprintCallable) line, then compile again |
| Changes to the header don’t appear | Close the editor and build from the IDE. Live Coding can’t always pick up header changes |
| “Could not be compiled. Try rebuilding from source” | Build from the IDE to see the real error |
| Unresolved external symbol | See LNK2001 unresolved external symbol |
Let AI help, but read what it writes. AI assistants are good at turning a Blueprint description into Unreal C++ and explaining each line. You still need to compile, test and understand the result. See how to use Claude Code with Unreal Engine.
FAQ
Do I need to know C++ before starting? No. Starting with one small component like this one is a good way to learn.
Is C++ always faster than Blueprints? For heavy maths and big loops, yes. For simple events the difference is usually too small to matter.
Should I convert my Blueprints to C++ to get ready for UE6? No. The C++ Gameplay Framework is leaving UE6 too. Convert only what makes your UE5 game better.
Related reading
C++ power, Blueprint simplicity. Our plugins follow the same pattern as this tutorial: the heavy work in C++, used from Blueprints. For example, Game Thread Rigs lets you drive Control Rigs in your Animation Blueprint from Blueprints for procedural animation. Browse all our Unreal plugins.