Weapon SwitchingCombat

Player carries multiple discrete weapons with different properties; active weapon is selected from inventory.

Switching the active melee weapon changes reach and swing speed — long slow axe, short fast mace you step in with, balanced sword.

How weapon switching works in Godot

Carrying multiple weapons is a data problem, not a scene problem: an array of weapon definitions plus an index for the active one.

Resourceprimitive

Each weapon is a WeaponData resource — damage, fire rate, ammo type, sprite. Defining weapons as data lets you add more without new code.

class_name WeaponData extends Resource
@export var name: String
@export var damage: int
@export var fire_rate: float

Arrayprimitive

The owned weapons list. Cycling is just walking the array; picking one up appends to it.

var owned: Array[WeaponData] = []
var active := 0

func cycle():
    active = (active + 1) % owned.size()

Signalsprimitive

Emit weapon_changed on swap so the HUD icon and the firing code both react, instead of each polling the index.

signal weapon_changed(w)
func set_active(i):
    active = i
    weapon_changed.emit(owned[i])

In short: Array of WeaponData Resources in player state; active_weapon_index int; swap on input event

Retro games that use weapon switching

78 catalogued game(s) use this mechanic, spanning 1986–1999.

Related combat mechanics

▶ Explore Weapon Switching interactively — see every game + the Godot system