Actors & Components
Actors are the fundamental entities that populate a UE5 level. Every object you see — from a rock to a playable character — is an Actor containing one or more Components.
What is an Actor?
An Actor is any object that can be placed or spawned in a level.
Actors support 3D transformations (location, rotation, scale) and can contain an
arbitrary collection of Components that define their behavior and appearance.
AActor is the base C++ class for all actors.
Actors do not have a transform by themselves — they get their transform from a special Root Component. The root component establishes the origin point for the Actor in world space.
Actor Lifecycle
Every Actor goes through a well-defined lifecycle:
- SpawnActor — The world spawns the actor (allocates memory, calls constructor).
- BeginPlay — Called once when the game starts or the actor is spawned mid-game.
- Tick — Called every frame (if
PrimaryActorTick.bCanEverTick = true). - EndPlay — Called when the actor is destroyed or the level ends.
- Destroy — Memory is freed.
Components
Components are modular pieces of functionality attached to an Actor. They can represent geometry, collision, audio, physics, camera, and much more. UE5 includes dozens of built-in component types, and you can create custom components in C++ or Blueprint.
| Component | Class | Purpose |
|---|---|---|
| Scene Component | USceneComponent | Has a transform. Root of any component hierarchy. |
| Static Mesh | UStaticMeshComponent | Renders a static 3D mesh. |
| Skeletal Mesh | USkeletalMeshComponent | Animated mesh driven by a skeleton. |
| Box Collision | UBoxComponent | Box-shaped collision volume. |
| Sphere Collision | USphereComponent | Sphere-shaped collision volume. |
| Camera | UCameraComponent | Defines a camera view. |
| Point Light | UPointLightComponent | Omni-directional light source. |
| Audio | UAudioComponent | Plays a sound in 3D space. |
| Particle System | UNiagaraComponent | Niagara VFX particle emitter. |
| Character Movement | UCharacterMovementComponent | Provides walking, jumping, swimming, flying. |
Creating an Actor in C++
The following example creates a custom Actor with a Static Mesh component and a Box Collision component. The actor pulses its material scalar parameter over time.
// MyPulsingActor.h
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "MyPulsingActor.generated.h"
UCLASS()
class MYGAME_API AMyPulsingActor : public AActor
{
GENERATED_BODY()
public:
AMyPulsingActor();
protected:
virtual void BeginPlay() override;
virtual void Tick(float DeltaTime) override;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
UStaticMeshComponent* MeshComp;
UPROPERTY(VisibleAnywhere)
UBoxComponent* TriggerBox;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Pulse")
float PulseSpeed = 2.0f;
private:
UMaterialInstanceDynamic* DynMat;
float ElapsedTime = 0.f;
};
// MyPulsingActor.cpp
#include "MyPulsingActor.h"
#include "Components/BoxComponent.h"
#include "Components/StaticMeshComponent.h"
#include "Materials/MaterialInstanceDynamic.h"
AMyPulsingActor::AMyPulsingActor()
{
PrimaryActorTick.bCanEverTick = true;
// Root collision box
TriggerBox = CreateDefaultSubobject<UBoxComponent>(TEXT("TriggerBox"));
SetRootComponent(TriggerBox);
TriggerBox->SetBoxExtent(FVector(50.f));
// Visible mesh attached to root
MeshComp = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh"));
MeshComp->SetupAttachment(TriggerBox);
}
void AMyPulsingActor::BeginPlay()
{
Super::BeginPlay();
// Create a dynamic material instance so we can change parameters at runtime
DynMat = MeshComp->CreateAndSetMaterialInstanceDynamic(0);
}
void AMyPulsingActor::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
ElapsedTime += DeltaTime;
if (DynMat)
{
const float PulseValue = (FMath::Sin(ElapsedTime * PulseSpeed) + 1.f) * 0.5f;
DynMat->SetScalarParameterValue(TEXT("EmissiveIntensity"), PulseValue * 5.f);
}
}
Blueprint Actor Example
The same pulsing actor can be created entirely in Blueprint using the Construction Script for setup and the Event Graph for runtime logic:
Spawning Actors at Runtime
Actors are spawned at runtime via the world's SpawnActor templated function.
You specify the class, transform, and optional spawn parameters:
// Spawn a projectile at the muzzle socket
FActorSpawnParameters SpawnParams;
SpawnParams.Owner = this;
SpawnParams.Instigator = GetInstigator();
SpawnParams.SpawnCollisionHandlingOverride =
ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButAlwaysSpawn;
FVector SpawnLoc = GetActorLocation() + GetActorForwardVector() * 100.f;
FRotator SpawnRot = GetActorRotation();
AMyProjectile* Projectile = GetWorld()->SpawnActor<AMyProjectile>(
ProjectileClass, SpawnLoc, SpawnRot, SpawnParams);
Always check that SpawnActor did not return nullptr before using the result. Spawn may fail if the location overlaps with blocking geometry and no adjustment is possible.