Components¶
Components are reusable pieces of functionality you attach to actors. The two roots:
| Base | Has transform? | Examples |
|---|---|---|
UActorComponent |
No | UMovementComponent, UAbilitySystemComponent, audio non-spatial |
USceneComponent |
Yes | UStaticMeshComponent, UCameraComponent, UWidgetComponent |
Categories¶
Rendering¶
UStaticMeshComponentUSkeletalMeshComponentUInstancedStaticMeshComponent/UHierarchicalInstancedStaticMeshComponent(ISM/HISM)UDecalComponentUWidgetComponent— UMG in 3D spaceUSceneCaptureComponent2D/CubeUPostProcessComponentUNiagaraComponent
Collision / Physics¶
UBoxComponent,USphereComponent,UCapsuleComponentUPrimitiveComponent(base for collide-able shapes)URigidBodyComponent/UPhysicsConstraintComponent
Movement¶
UMovementComponent(base)UCharacterMovementComponentUProjectileMovementComponentUFloatingPawnMovementUChaosVehicleMovementComponent
Audio¶
UAudioComponentUAmbientSoundComponent
AI¶
UBlackboardComponentUBehaviorTreeComponentUAIPerceptionComponentUPathFollowingComponent
Camera¶
UCameraComponentUCineCameraComponentUSpringArmComponent
Gameplay¶
UAbilitySystemComponent(GAS)UHealthComponent(custom pattern)UInventoryComponent(custom pattern)
Special¶
UTextRenderComponent— 3D textUArrowComponent— editor visualizationUBillboardComponent— facing-camera sprite
Attachment¶
SceneComponent has a parent → child tree. Attach with:
Or AttachToSocketName for skeletal mesh sockets.
Replication¶
Components don't automatically replicate. Mark bReplicates = true on the component, and the owning Actor must also be replicated.
Creating in C++¶
UStaticMeshComponent* Mesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh"));
SetRootComponent(Mesh);
Creating from Blueprint¶
+ Component in the BP editor. Choose any registered component class.
Custom components¶
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
class MYGAME_API UHealthComponent : public UActorComponent
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite) float Max = 100.f;
UPROPERTY(BlueprintReadOnly, ReplicatedUsing=OnRep_Current) float Current = 100.f;
UFUNCTION() void OnRep_Current();
};
Performance¶
- Each ticking component costs main-thread time. Disable Tick on components that don't need it.
- ISM/HISM consolidates thousands of meshes into one draw call — huge win for PCG-spawned content.
- WidgetComponent in 3D space rasterizes UMG to a render target every frame it changes — pin it to manual redraws if static.