Weapons
For creatorsAdd-on 2.2.2+
The third-person hero’s weapons come from a weapons table: a data table your scene carries, one row per weapon. A row says what the weapon is, how hard it hits, which model the hero holds and which key picks it. A gun can also bring its own fire and reload clips. Your scene needs the hero first; see The player hero.
Add a weapons table
Section titled “Add a weapons table”- In Blender, open a Text Editor and press New.
- Name the text
data/weapons.json. - Paste a table, such as the one below.
- Turn on the text’s fake user (the shield button) so Blender keeps it when you save.
{ "format": 1, "rows": [ { "id": "bat", "name": "Bat", "kind": "melee", "damage": 34, "reach": 1.1, "arc": 130, "cleave": 3, "knock": 0.9, "stagger": 0.6, "cooldown": 0.55, "noise": 0, "ammo": -1, "hotkey": "1", "grip": "bat", "model": "Bat" }, { "id": "pistol", "name": "Pistol", "kind": "gun", "damage": 30, "reach": 35, "pierce": 1, "knock": 0.25, "stagger": 0.25, "cooldown": 0.28, "noise": 22, "ammo": 48, "hotkey": "2", "grip": "pistol", "model": "Pistol" }, { "id": "rifle", "name": "Rifle", "kind": "gun", "damage": 24, "reach": 50, "pierce": 2, "knock": 0.15, "stagger": 0.15, "cooldown": 0.11, "noise": 35, "ammo": 120, "hotkey": "3", "grip": "rifle", "model": "Rifle" }] }The table travels with the scene when you build it. To use a table with another name, give its name in the scene’s player.weapons.
More about tables is on Data tables.
Columns
Section titled “Columns”| Column | Values | What it does |
|---|---|---|
id |
Text. Required | The weapon’s name in tags such as player.weapons.start and smart.weapon |
name |
Text. Default: the id |
The name the player sees |
kind |
melee (default) · gun |
A melee weapon swings along the way the hero faces. A gun shoots where the crosshair is, from the muzzle |
model |
An object’s name | The model the hero holds. Place it anywhere in the scene: the hero takes it from there |
grip |
pistol · rifle · bat. Default: pistol for a gun, bat for melee |
How the hero holds it: a pistol along the right forearm, a rifle in both hands, a bat carried low and swung |
hotkey |
A key, such as 1 |
The key that picks this weapon |
cooldown |
Seconds. Default 0.4 |
The time between attacks |
ammo |
Rounds. Default -1 (endless) |
Rounds the gun starts with. The display shows ∞ for endless |
damage |
Default 20 |
How much one hit takes |
reach |
Metres. Default 30 for a gun, 1 for melee |
A gun’s range, or how far past a body’s edge a swing reaches |
arc |
Degrees. Default 120 |
How wide a melee swing is |
cleave |
Default 3 |
The most bodies one swing hits |
pierce |
Default 1 |
How many bodies one shot passes through |
knock |
Metres. Default 0 |
How far a hit pushes a body back |
stagger |
Seconds. Default 0 |
How long a struck body stands dazed |
noise |
Metres. Default 0 |
How far away hunters hear it |
Give a gun its model, grips and clips
Section titled “Give a gun its model, grips and clips”- Model the gun pointing down −Y, with its origin where the right hand holds it.
- Name the object as the row’s
modelsays, such asPistol. - Select it and, in Properties ▸ Object ▸ Simulacrum, choose Make ▸ Make Hand Item ▸ Pistol or Rifle. Move
grip.r,grip.landmuzzleto fit. See Hand items. - Make its slide, trigger, hammer and magazine moving parts, and key its Fire and Reload clips with Make Item Clip in the Item panel. See Moving parts.
In play, every shot plays the gun’s own Fire clip, whichever body the hero wears. Signed in to MegaCity, the hero holds the gun by its grips and aims it at the crosshair, and R plays the gun’s Reload clip with the body’s own reload. Signed out, the hero’s arms hold a pistol out in both hands or shoulder a rifle, and there is no reload key.
A gun without grips gets them from its bounds, with the right hand just under its origin.
Choose what the hero starts with
Section titled “Choose what the hero starts with”player.weapons.start on the scene lists the weapon ids the hero starts with, separated by commas.
| Value | The hero starts with |
|---|---|
| None (the tag left out) | Every weapon in the table |
pistol,rifle |
Those weapons |
none |
Nothing in its hands |
Hotkeys and swapping
Section titled “Hotkeys and swapping”- A row’s
hotkeypicks that weapon: press 1 for the row with"hotkey": "1". - Q and the mouse wheel step through the weapons the hero owns. On a gamepad, the top face button does.
- The hero swaps only between weapons it owns.
The fire button is the scene’s fire action. To fire with another action, name it in the scene’s weapon.action. Bind fire to
F and the mouse (input.fire = keys:KeyF ; mouse:left); G is Drop while the hero carries something. See
Controls for your scene.
Weapons to pick up
Section titled “Weapons to pick up”A weapon can lie in the scene for the hero to find. Tag its object:
| Tag | Values | What it does |
|---|---|---|
smart |
A kind, such as pistol |
Makes it a smart object |
smart.carry |
pistol · rifle · bat |
It can be picked up, and how it is held |
smart.weapon |
A row’s id |
Picked up with E, it joins the hero’s weapons, in its hands at once |
Ammo crates in a horde
Section titled “Ammo crates in a horde”In a horde scene, an ammo crate refills a gun when the hero walks over it.
| Tag | Values | What it does |
|---|---|---|
pickup |
ammo |
Makes the object an ammo crate |
pickup.weapon |
A row’s id. Default: the first gun with limited ammo |
The gun it refills |
pickup.amount |
Rounds. Default 25 |
How many rounds it gives |
pickup.respawn |
Seconds. Default 20 |
How long until it comes back |
Limits
Section titled “Limits”- Hits need a game that counts them. The hero aims, fires, swaps, spends ammo and waits out each cooldown in any scene. Damage, reach, arc, cleave, pierce, knock, stagger and noise take effect in a game that resolves hits, such as the horde. In other scenes a shot hits nothing.
- Reload is for signed-in players only, and has no gamepad button yet.
- A
batgrip is held by the arms, not by grips. The bat is carried low and swung along an arc, signed in or not.
Play ▶ the horde to see the bat, the pistol and the rifle from the table above. The tutorial The horde in third person builds it.