Log inGet started
World

Procgen Effects Showcase

Branchmain
Branchesmain
Commit99ff90d12c

README.md

tracer

The glowing streak of a round in flight: a white-hot streak leaving the muzzle along -Z and burning out distance metres on, shedding embers that fall and cool behind it.

Fire it at the muzzle with its -Z turned toward what the round hits, and distance the range to it:

-- `graph` is this graph's reference: the AssetRef `asset.resolve` or a search returns for it.
local function tracer(from, to)
    local dx, dy, dz = to[1] - from[1], to[2] - from[2], to[3] - from[3]
    local e = entity.spawn("tracer", { position = from, temporary = true })
    e:lookAt(to)
    e.component.add("Generator", {
        graph = graph, playOn = "load", ending = "hold",
        params = { distance = math.sqrt(dx * dx + dy * dy + dz * dz) },
    })
    e.component.get("Generator").events.onFinished:connect(function()
        e:despawn()
    end)
    return e
end
InputDefaultWhat it does
distance40How far the round flies before it burns out, in metres: the range to what it hits.
speed240How fast it flies, in metres per second.
width0.04Width of the streak, in metres.

The streak runs back from the round for as far as it flies in a sixtieth of a second, and never behind the muzzle. It plays 45 frames at 60 fps (0.75 s). Each distance is its own set of frames: plays at one range share what the first one cooked.