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โ
local myDecal = Decal(
Vector(100, 200, 0),
Rotator(0, 90, 90),
"/Engine/EngineMaterials/DefaultDecalMaterial.DefaultDecalMaterial",
Vector(128, 256, 256),
60,
0.01
)
| Name | Type | Default | Description |
|---|---|---|---|
Location | Vector | Required | World position for the center of the decal projection |
Rotation | Rotator | Required | Orientation of the decal in world space |
MaterialAsset | string | Required | Path to a decal-compatible material |
Size | Vector | (128, 256, 256) | Size of the decal (depth, height, width) |
Lifespan | number | 60 | Seconds to live before destroying (0 = infinite) |
FadeScreenSize | number | 0.01 | Screen 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โ iftrue, 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())