Skip to main content

FX (Visual Effects)

Version History

Build VersionChange DateChange TypeDescription
6760422025-06-21stableCurrent version

Overview

The FX system provides a comprehensive collection of visual effects for Don't Starve Together. It defines animation-based particle effects, screen overlays, impact effects, transformation sequences, and environmental animations. Effects are defined as data tables with animation banks, builds, sounds, and custom initialization functions.

Usage Example

-- Spawn a basic effect
local splash_fx = SpawnPrefab("splash")

-- Spawn effect at specific location
local x, y, z = inst.Transform:GetWorldPosition()
local puff_fx = SpawnPrefab("sand_puff")
puff_fx.Transform:SetPosition(x, y, z)

-- Effects with custom properties
local shock_fx = SpawnPrefab("shock_fx")
shock_fx.Transform:SetRotation(45) -- Many effects support rotation

FX Definition Structure

Each effect in the fx table follows this structure:

{
name = "effect_name", -- Prefab name for spawning
bank = "animation_bank", -- Animation bank file
build = "animation_build", -- Animation build file
anim = "animation_name", -- Animation to play
sound = "sound/path", -- Optional sound effect
transform = Vector3(x, y, z), -- Optional scale transform
tint = Vector3(r, g, b), -- Optional color tint
tintalpha = 0.5, -- Optional alpha transparency
fn = CustomFunction, -- Optional initialization function
bloom = true, -- Optional bloom effect
autorotate = true, -- Optional auto-rotation
-- Additional specialized properties...
}

Core Helper Functions

FinalOffset Functions

local function FinalOffset1(inst)
inst.AnimState:SetFinalOffset(1)
end

local function FinalOffset2(inst)
inst.AnimState:SetFinalOffset(2)
end

local function FinalOffset3(inst)
inst.AnimState:SetFinalOffset(3)
end

Description: Set the rendering layer offset for proper depth sorting.

UsePointFiltering(inst)

Status: stable

Description: Enables point filtering for pixelated/crisp rendering instead of smooth interpolation.

Parameters:

  • inst (Entity): The effect entity instance

Example:

fn = UsePointFiltering

GroundOrientation(inst)

Status: stable

Description: Sets the effect to render flat on the ground surface with appropriate layer settings.

Parameters:

  • inst (Entity): The effect entity instance

Example:

fn = GroundOrientation

Bloom(inst)

Status: stable

Description: Applies bloom shader effect and sets final offset for glowing effects.

Parameters:

  • inst (Entity): The effect entity instance

Example:

fn = Bloom

Effect Categories

Impact Effects

Effects that trigger on collision or interaction:

Effect NameDescriptionSoundUsage
splashWater splash effectBird splashWater entry
frogsplashFrog-specific splashFrog splashFrog jumping
shock_fxElectric shock effectShock soundLightning damage
mining_fxRock mining debrisNoneMining rocks
glass_fxGlass breaking effectSand to glassGlass creation

Example:

-- Spawn splash effect when entering water
local splash = SpawnPrefab("splash")
splash.Transform:SetPosition(x, y, z)

Transformation Effects

Effects for character or object transformations:

Effect NameDescriptionDurationSpecial Properties
werebeaver_transform_fxWoodie beaver form~2 secondsDeath poof sound
weremoose_transform_fxWoodie moose form~1.5 secondsMultiple stages
beefalo_transform_fxBeefalo domestication~1 secondFinal offset
attune_in_fxPortal attunement in~1 secondGhost haunt sound
attune_out_fxPortal attunement out~1 secondGhost haunt sound

Example:

-- Trigger transformation effect
local transform_fx = SpawnPrefab("werebeaver_transform_fx")
transform_fx.Transform:SetPosition(player.Transform:GetWorldPosition())

Particle Effects

Environmental and atmospheric effects:

Effect NameTypeProperties
sand_puffDust cloudDeathpoof sound
small_puffSmall smokeSmoke animation
shadow_puffDark particleBlack tint, 50% alpha
dirt_puffSoil particlesFinal offset 1
emote_fxEmote particlesAuto-rotate, final offset

Example:

-- Create dust effect when digging
local dust = SpawnPrefab("sand_puff")
dust.Transform:SetPosition(x, y, z)

Combat Effects

Effects related to combat and damage:

Effect NamePurposeVisual Style
groundpound_fxGround slam impactDust cloud with sound
firesplash_fxFire damage burstBloom effect
shadowstrike_slash_fxShadow weapon attackEight-faced scaling
minotaur_blood1/2/3Blood splatterSemi-transparent red

Example:

-- Add combat impact effect
local impact = SpawnPrefab("groundpound_fx")
impact.Transform:SetPosition(target.Transform:GetWorldPosition())

Weather and Environmental Effects

Effects for weather and environmental changes:

Effect NameEnvironmentProperties
splash_snow_fxWinter/SnowFire suppresser impact sound
green_leaves_chopForest/TreesLeaf rustle sound
oceantree_leaf_fx_fallOcean/IslandsFalling animation with physics
halloween_firepuff_1/2/3SeasonalBloom with fire sound

Character-Specific Effects

Effects tied to specific characters:

Wendy/Abigail Effects

"ghostlyelixir_slowregen_fx"     -- Abigail regeneration buff
"ghostlyelixir_attack_fx" -- Abigail attack buff
"ghostlyelixir_shield_fx" -- Abigail shield buff
"abigail_attack_shadow_fx" -- Shadow attack ground effect

Wanda Time Effects

"oldager_become_younger_front_fx" -- Age reversal effect
"oldager_become_older_fx" -- Aging effect
"pocketwatch_heal_fx" -- Pocket watch healing

Wolfgang Effects

"wolfgang_mighty_fx"             -- Mighty form transformation

Wortox Effects

"wortox_soul_spawn_fx"           -- Soul spawning
"wortox_teleport_reviver_top" -- Teleport revival effect

Dynamic Effect Generation

The system dynamically generates effects for certain categories:

Crater Steam Effects

-- Generates crater_steam_fx1 through crater_steam_fx4
for cratersteamindex = 1, 4 do
table.insert(fx, {
name = "crater_steam_fx"..cratersteamindex,
bank = "crater_steam",
build = "crater_steam",
anim = "steam"..cratersteamindex,
fn = FinalOffset1,
})
end

Slingshot Ammo Hit Effects

-- Generates hit effects for different ammo types
local SHOT_TYPES = {
"rock", "gold", "marble", "thulecite", "honey",
"freeze", "slow", "poop", "moonglass", "dreadstone",
"gunpowder", "lunarplanthusk", "purebrilliance"
}

-- Creates slingshotammo_hitfx_[type] for each type

Shadow Shield Effects

-- Generates shadow_shield1 through shadow_shield6
-- with mirrored versions for different orientations

Effect Properties Reference

Common Properties

PropertyTypeDescription
namestringPrefab name for spawning
bankstringAnimation bank file
buildstringAnimation build file
animstring/functionAnimation name or function returning name
soundstringSound effect path
sounddelaynumberDelay before playing sound

Transform Properties

PropertyTypeDescription
transformVector3Scale transformation
autorotatebooleanEnable automatic rotation
eightfacedbooleanEight-directional facing
fourfacedbooleanFour-directional facing
twofacedbooleanTwo-directional facing
sixfacedbooleanSix-directional facing
nofacedbooleanNo directional facing

Visual Properties

PropertyTypeDescription
tintVector3RGB color tint (0-1)
tintalphanumberAlpha transparency (0-1)
bloombooleanEnable bloom shader effect
fnfunctionCustom initialization function

Animation Properties

PropertyTypeDescription
animqueuebooleanQueue multiple animations
update_while_pausedbooleanUpdate during pause

Creating Custom Effects

Basic Custom Effect

local custom_fx = {
name = "my_custom_effect",
bank = "my_fx_bank",
build = "my_fx_build",
anim = "my_animation",
sound = "my_mod/effects/custom_sound",
fn = function(inst)
inst.AnimState:SetFinalOffset(1)
inst.AnimState:SetScale(1.5, 1.5, 1.5)
end
}

table.insert(fx, custom_fx)

Advanced Custom Effect with Physics

local advanced_fx = {
name = "falling_leaf_custom",
bank = "leaf_fx",
build = "leaf_fx",
anim = "fall",
fn = function(inst)
local scale = 1 + 0.3 * math.random()
inst.Transform:SetScale(scale, scale, scale)

-- Add falling physics
inst.fall_speed = 2.0 + 1.5 * math.random()
inst:DoPeriodicTask(FRAMES, function(inst)
local x, y, z = inst.Transform:GetWorldPosition()
inst.Transform:SetPosition(x, y - inst.fall_speed * FRAMES, z)
end)
end
}

Performance Considerations

  • Effects are temporary entities that clean up automatically
  • Use appropriate final offsets to avoid rendering conflicts
  • Large-scale effects should use efficient animation techniques
  • Sound effects should be optimized for multiple simultaneous plays