RealDocs

UGameplayStatics::SpawnDecalAtLocation

function Engine Blueprint Since 4.0
#include "Kismet/GameplayStatics.h"
Access: public Specifiers: staticUFUNCTIONBlueprintCallableBlueprintCosmetic

Description

Spawns a decal projector at a fixed world position. The decal is cosmetic only and does not replicate — use it for bullet holes, blood splats, and other client-side surface marks.

Caveats & Gotchas

  • Marked BlueprintCosmetic — this call is skipped entirely on dedicated servers; do not rely on it for gameplay-relevant state.
  • The default rotation (-90, 0, 0) points the decal downward; for wall or ceiling decals derive the rotation from the hit normal returned by a line trace.
  • Decals spawned with LifeSpan = 0 persist forever and accumulate memory; set a finite lifespan or pool/limit them yourself.

Signature

static ENGINE_API UDecalComponent* SpawnDecalAtLocation(const UObject* WorldContextObject, class UMaterialInterface* DecalMaterial, FVector DecalSize, FVector Location, FRotator Rotation = FRotator(-90, 0, 0), float LifeSpan = 0);

Parameters

Name Type Description Default
WorldContextObject const UObject* Object used to resolve the current world.
DecalMaterial class UMaterialInterface* The decal material to project onto surfaces.
DecalSize FVector Size of the decal projection box in world units.
Location FVector World-space position to place the decal.
Rotation FRotator World-space rotation of the decal projection box. FRotator(-90, 0, 0)
LifeSpan float Seconds until the decal component is automatically destroyed. 0 = never. 0

Return Type

UDecalComponent*

Example

Spawn a bullet hole decal on impact C++
void AMyProjectile::OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor,
    UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
{
    // Orient the decal so it faces along the surface normal.
    FRotator DecalRot = Hit.ImpactNormal.Rotation();
    UGameplayStatics::SpawnDecalAtLocation(
        this, BulletHoleMaterial,
        FVector(5.f, 5.f, 5.f),
        Hit.ImpactPoint,
        DecalRot,
        10.0f  // auto-destroy after 10 seconds
    );
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.