weapon_2d
2D: guns. The object carries weapons and aims them (players: mouse or right stick, with aim assist; others: their script's self.aimAt / self.shoot), or with pickup true it is a gun on the ground for the player to take. Weapons are data: built-ins pistol, smg, shotgun, rifle, rocket, laser, orb (slow glowing enemy bullets), turret, or Assets/Weapons/
In scene text
weapon_2d { weapon "…" carried ["a", "b"] ammo ["a", "b"] }Add it in the Inspector (Add Component), in scene text as above, or ask your AI. Fields you leave out keep their defaults.
Fields 21
| Field | Type | Unit / range | What it does |
|---|---|---|---|
weapon | text | — | The weapon in hand: pistol, smg, shotgun, rifle, rocket, laser, orb, turret, or a project weapon file's name. |
carried | list of text | — | Everything it carries (switch with Q, 1-6, the pad's Y): ["pistol", "shotgun"]. |
ammo | list of text | — | Spare rounds: ["shotgun=24", "all=200"] (unlisted: the weapon's own reserve; -1 endless). |
tune | list of text | — | This object's changes to weapon settings: ["knockback=900", "shotgun.pellets=10", "fire_rate=12", "auto=true"]. weapon_2d_presets lists every setting. |
control | text | — | auto |
aim_assist | number | 0 … 1 | Gamepad aim assist: 0 none ... 1 strong (bends the stick's aim toward the closest enemy in a cone). |
shoulder | (x, y, z) | units | Where the arm turns from the position (art facing right; mirrored when aiming left). |
arm | text | — | |
arm_length | number | units, 0 … 400 | Shoulder to grip. |
arm_width | number | units, 0 … 200 | The drawn arm's thickness. |
arm_rect | (x, y, z) | units | Where the arm picture lies along the arm from the shoulder: (start, end, thickness); zero: automatic. |
draw_gun | true / false | — | Draws the gun (and arm) turned to the aim. |
gun_layer | number | -100 … 100 | Drawn at the sprite's layer plus this (negative: behind the body). |
gun_scale | number | 0.05 … 20 | Scales the drawn gun. |
face_aim | true / false | — | Turns the sprite or rig to face the aim. |
crosshair | true / false | — | Players: a crosshair at the aim that opens with spread and shows hit markers. |
aim_lead | number | units, 0 … 1000 | Players: the camera leans this far toward the aim. |
pickup | true / false | — | A gun on the ground: the first player to touch it takes weapon (and pickup_ammo rounds); weapon "ammo" refills what it carries. |
pickup_ammo | number | 0 … 100000 | Rounds a pickup gives (0: the weapon's reserve). |
pickup_radius | number | units, 1 … 2000 | How close a player must come to take a pickup. |
enabled | true / false | — | On. |