muzzleFlash.procGraph
The bloom at a barrel the instant a weapon fires: a ragged star of light and a tongue of flame down the bore, gone within three frames; a spray of burning powder that streaks out, falls and cools; a few puffs of smoke that swell, rise and thin; and a light that throws the flash o…
muzzleFlash
The bloom at a barrel the instant a weapon fires: a ragged star of light and a tongue of flame down the bore, gone within three frames; a spray of burning powder that streaks out, falls and cools; a few puffs of smoke that swell, rise and thin; and a light that throws the flash on whatever stands near.
The bore runs along the effect's -Z. Stand it on a child of the weapon at the muzzle, so it follows the weapon, and play it from the start on each shot:
-- `graph` is this graph's reference: the AssetRef `asset.resolve` or a search returns for it.
local function mountFlash(weapon, muzzleOffset)
local muzzle = entity.spawn("muzzle", { parent = weapon.id, position = muzzleOffset })
muzzle.component.add("Generator", { graph = graph, playOn = "manual", ending = "hold" })
local flash = muzzle.component.get("Generator")
return function()
flash:seek(0)
flash:play()
end
end
| Input | Default | What it does |
|---|---|---|
size | 0.28 | Width of the flash in metres: a pistol at 0.12, a rifle at 0.28, a tank gun at 1.2. Every layer scales with it. |
light | 1 | Strength of the light it throws, as a multiple of the default. |
It plays 54 frames at 60 fps (0.9 s). Played again, it plays the frames its first play cooked, so a weapon firing on full auto cooks it once.
Scoped to this part · feeds back into the world's score.