projectile
A projectile reference points at one projectile a fighter spawned. Use its methods with a colon, such as projectile:snapshot(). A reference stops working after the callback that gave it to you finishes.
projectile:snapshot
Section titled “projectile:snapshot”Copy a live projectile’s position and lifetime.
Signature: projectile:snapshot()
Returns: A snapshot (id, name, animation_name, position, age_frames, lifetime_frames), or nil, error once the projectile is gone.
When: The callback that obtained the projectile
local view = projectile:snapshot()if view then sf2.log.info("x=" .. view.position.x) endThe copy stays valid later; the projectile reference does not.
projectile:move_by
Section titled “projectile:move_by”Shift the whole projectile by a set distance. Its declared velocity still applies.
Signature: projectile:move_by(x, y, z?)
Parameters
| Parameter | Type | Required |
|---|---|---|
x |
number |
Required |
y |
number |
Required |
z |
number? |
Required |
Returns: true, nil when queued, or false, error when rejected.
When: The callback that obtained the projectile
local view = projectile:snapshot()if view then local dx = math.max(-10, math.min(10, target_x - view.position.x)) projectile:move_by(dx, 0)endUse zero velocity in the definition when Lua supplies all the motion. The shift is a jump with no swept collision, so large steps can skip over contact. It is discarded if the projectile hits, expires or is removed first.
projectile:remove
Section titled “projectile:remove”Delete this projectile; the reference stops working immediately.
Signature: projectile:remove()
Returns: true, nil when accepted, or false, error if already gone.
When: The callback that obtained the projectile
local view = projectile:snapshot()if view and math.abs(view.position.x - launch_x) < 12 then projectile:remove()endRemoving creates no hit, damage or animation callback. Projectiles are also removed when the round ends, the owner dies or changes form, or the owning actor goes away.