UGameplayStatics::SpawnDecalAttached
#include "Kismet/GameplayStatics.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintCallableBlueprintCosmetic
Description
Spawns a decal projector that follows an attached component, such as a bone on a skeletal mesh. Use this for decals that need to move with an actor, like a wound mark on a character.
Caveats & Gotchas
- • Like SpawnDecalAtLocation, this is BlueprintCosmetic — it runs only on clients and is skipped on dedicated servers.
- • Attaching to a skinned mesh bone works at runtime, but the decal position won't update per-vertex deformation — it tracks the bone transform only, which may look incorrect on highly deformed meshes.
Signature
static ENGINE_API UDecalComponent* SpawnDecalAttached(class UMaterialInterface* DecalMaterial, FVector DecalSize, class USceneComponent* AttachToComponent, FName AttachPointName = NAME_None, FVector Location = FVector(ForceInit), FRotator Rotation = FRotator::ZeroRotator, EAttachLocation::Type LocationType = EAttachLocation::KeepRelativeOffset, float LifeSpan = 0); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| DecalMaterial | class UMaterialInterface* | The decal material to project. | — |
| DecalSize | FVector | Size of the decal projection box in world units. | — |
| AttachToComponent | class USceneComponent* | Component to attach the decal to; the decal will follow it. | — |
| AttachPointName | FName | Optional socket or bone name on AttachToComponent. | NAME_None |
| Location | FVector | Offset from the attachment point, interpreted per LocationType. | FVector(ForceInit) |
| Rotation | FRotator | Rotation offset from the attachment point. | FRotator::ZeroRotator |
| LocationType | EAttachLocation::Type | Whether Location/Rotation are relative to the attach point or absolute world values. | EAttachLocation::KeepRelativeOffset |
| LifeSpan | float | Seconds until the decal component is automatically destroyed. 0 = never. | 0 |
Return Type
UDecalComponent* Example
Attach a wound decal to a character mesh bone C++
// Attach a blood decal to the hit bone of a skeletal mesh.
USkeletalMeshComponent* Mesh = HitActor->FindComponentByClass<USkeletalMeshComponent>();
if (Mesh)
{
UGameplayStatics::SpawnDecalAttached(
BloodDecalMaterial,
FVector(8.f, 8.f, 8.f),
Mesh,
HitBoneName,
FVector::ZeroVector,
FRotator::ZeroRotator,
EAttachLocation::SnapToTarget,
15.0f
);
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?