gunHow to add new weapon and ammo

Tutorial help you to understand how to add new weapons and ammo to the game

Files & folders needed:

assets/gameplay/items.json

assets/gameplay/weapons.json

assets/texts/lang_*.json

In previous tutorial we created obrez weapon hud:

hand-holding-magicHow to add weapon HUD imagechevron-right

Now lets create in any image editor ammo icon for this obrez weapon:

Buckshot ammo 12x70mm

Save it to assets/ui/items/.

Open assets/gameplay/items.json and create new duplicate ammo structure and change it's ID to new one:

Add name and caption texts to the assets/texts/lang_*.json (* - means any language available there)

Create duplacate copy of existing weapon item in assets/gameplay/items.json:

Then open assets/gameplay/weapons.json to create new weapon JSON structure profile:

circle-info

fire_sound use sound name from assets/sounds/ folder.

sparkle_position and hud_position is [X, Y, Z] position on screen. Actually HUD and sparkle is 3D planes that very close to camera. You can use my utility script "HUD Coordinator"arrow-up-right.

To connect "HUD Coordinator"arrow-up-right to the game, open assets/scripts/p_game.gd script and type this code into _ready() function:

Tool can move HUD and muzzle flash on screen by arrow keys. Basic controls is F3 for enable/disable in-game utility, UP, DOWN, LEFT, RIGHT, hold SHIFT to move muzzle flash instead HUD, press SPACE to copy positions in ready-to-use JSON properties to clipboard, then after you can Ctrl+V to paste values in weapons.json:

HUD Coordinator utility script

Now that's all. Add new weapon to the traders or add to inventory at the game start with scripts.

New weapon item
New weapon

Last updated