Ballistics modes: raycast vs projectile (travel time + bullet drop) #49
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The plan
Status: BACKBURNERED — filed 2026-11-15 at Zach's direction ("we can
backburner the idea for later"). No build authorized. When this is picked
up, breaking changes to the weapon/ballistics data shape are permitted;
none are to be made now.
The idea: weapons get a ballistics mode. Today every shot is a hitscan
raycast (
Firearm._cast_shot, firearm.gd:389) with a beam tracer. The newmode fires a simulated projectile with travel time and bullet drop,
rendered as a glowing bullet in flight.
The property
A mode key on the weapon struct, in the weapon's
datatable inb_properties(alongsidedamage,rpm,spread_deg,range,projectiles):data.ballistics:"raycast"|"projectile", default"raycast".The name is load-bearing:
projectilesalready exists and means pelletcount per shot (a shotgun fires N pellets), so the mode key must NOT be
called
projectile.ballisticsis the name.The two modes
fire_once()calls_cast_shotper pellet — instantintersect_ray(range default 60 m),damage with falloff,
WorldFx.tracerdraws the beam from the muzzle tothe hit point. Existing weapons keep this with no data changes.
fire_once, instead of_cast_shot, spawn aprojectile entity per pellet: a small glowing bullet leaving the muzzle
at muzzle velocity, gravity applied per physics frame, hit detection as
a short swept raycast each step (same
SHOT_MASKand exclusions as theraycast, so fast rounds don't tunnel). On hit it runs the SAME damage
path as the raycast (falloff,
damage_mult,Health.apply_damage,WorldFx.impact) so the two modes can't drift apart. On no hit insideits range it despawns. Shotguns just work: each pellet in the
projectilescount becomes its own projectile.The numbers
per-weapon value in the weapon data (the gun's velocity is part of the
calculation). Whether the bullet also contributes per caliber
(per-caliber base velocity, modified by the gun — the tier-model shape)
is open; see Open questions.
drops ~14 cm — visible but small; slower subsonic rounds drop a lot
more, which is where the bullet's subsonic tag ties in naturally.
b_properties.ammotable is currentlyEMPTY (a round is just a model, tags, value, weight). Velocity data —
wherever it lands — is new data to author.
The visuals
WorldFx.tracer).WorldFxeffect).Whether it reuses the bullet GLB or a cheap emissive mesh is open —
the GLB is 2.25 MB and a small emissive shape reads better at speed.
What it touches (when built)
firearm.gd: branch infire_onceon the mode; a new projectilenode/script with its own
_physics_process(velocity, gravity, swepthit test, despawn).
WorldFx: the glowing-bullet visual (beam stays raycast-only).ballisticskey (default raycast, so existingweapons need no edits); velocity data wherever it lands.
item_schema.gdcarries the defaults for the weapondata keys): the new key needs a schema entry to be authorable in the
editor.
hit).
Build order (when picked up)
What done looks like
A weapon with
ballistics: "projectile"fires a visible glowing bulletthat takes measurable time to arrive and drops over distance; a weapon
with
"raycast"(or no key) behaves exactly as today. Both modes applydamage through the same code. Tests cover a projectile's flight
(position, velocity, drop) and a hit.
Decisions already made
(per-weapon muzzle velocity in the weapon data).
data.ballistics,"raycast"default. (Notprojectile— that name collides with the pellet-count key.)
Open questions
the gun? (The tier model says the projectile gets stats from the bullet,
modified by the gun — but the gun's velocity is the confirmed input.)
Glow for every round, or only tracer-tagged rounds?
the ground as a physical round?
does the projectile also hit the shooter/friendlies?
anything else?