Skip to main content

Decal

Decal spawns a 3D projected material onto surfaces in the world. This is useful for things like graffiti, blood splatters, burn marks, ground targets, or bullet impacts. Decals can fade based on screen size and automatically destroy themselves after a set lifespan.

/// tip Decal is an Actor, so you can call any Actor functions ///

Constructorโ€‹

Example
local myDecal = Decal(
Vector(100, 200, 0),
Rotator(0, 90, 90),
"/Engine/EngineMaterials/DefaultDecalMaterial.DefaultDecalMaterial",
Vector(128, 256, 256),
60,
0.01
)
NameTypeDefaultDescription
LocationVectorRequiredWorld position for the center of the decal projection
RotationRotatorRequiredOrientation of the decal in world space
MaterialAssetstringRequiredPath to a decal-compatible material
SizeVector(128, 256, 256)Size of the decal (depth, height, width)
Lifespannumber60Seconds to live before destroying (0 = infinite)
FadeScreenSizenumber0.01Screen size threshold below which the decal fades out

Functionsโ€‹

SetDecalMaterialโ€‹

Changes the decalโ€™s material at runtime.

  • material: UMaterialInterface โ€” the material to project
myDecal:SetDecalMaterial(UE.UObject.Load("/Engine/EngineMaterials/M_DecalGeneric.M_DecalGeneric"))

GetDecalMaterialโ€‹

Returns the currently assigned material.

  • returns: UMaterialInterface
local mat = myDecal:GetDecalMaterial()

CreateDynamicMaterialInstanceโ€‹

Creates a dynamic material instance for modifying parameters.

  • returns: UMaterialInstanceDynamic
local dyn = myDecal:CreateDynamicMaterialInstance()
dyn:SetScalarParameterValue("Opacity", 0.5)

GetDecalMaterialInstanceโ€‹

Returns the dynamic material instance (if previously created).

  • returns: UMaterialInstanceDynamic | nil
local inst = myDecal:GetDecalMaterialInstance()

SetDecalColorโ€‹

Tints the decal color (if supported by the material).

  • color: Color โ€” RGBA tint
myDecal:SetDecalColor(Color(1, 0.2, 0.2, 1)) -- light red

GetDecalColorโ€‹

Gets the current color tint.

  • returns: Color
local color = myDecal:GetDecalColor()

SetFadeScreenSizeโ€‹

Controls how small the decal appears before fading out.

  • value: number โ€” fade threshold
myDecal:SetFadeScreenSize(0.005)

GetFadeScreenSizeโ€‹

Returns the current fade screen size threshold.

  • returns: number
print(myDecal:GetFadeScreenSize())

SetFadeOutโ€‹

Begins fade-out after a delay, with optional destruction

  • startDelay: number โ€” seconds to wait before starting the fade
  • duration: number โ€” seconds for the fadeโ€‘out to complete
  • bDestroyOwnerAfterFade: boolean โ€” if true, destroys the actor after fade completes
myDecal:SetFadeOut(1.5, 2.0, true)

SetFadeInโ€‹

Fades the decal in over time

  • startDelay: number โ€” seconds to wait before starting the fadeโ€‘in
  • duration: number โ€” seconds for the fadeโ€‘in to complete
myDecal:SetFadeIn(0.0, 1.25)

SetSortOrderโ€‹

Controls which decals are rendered in front (higher draws later).

  • sortOrder: integer โ€” render sort priority
myDecal:SetSortOrder(5)

GetSortOrderโ€‹

Gets the current sort order value.

  • returns: integer
print(myDecal:GetSortOrder())
โœจ