What is the best way to store/switch weapons

Godot Version

4.2.1

Question

I need a way to equip weapons in my RPG game and I could not find a way to have my weapons switch when a new one is needed. Right now I have my weapons under a Node2D so then I can collapse them all.

Yes your way is good, it is the common way but I think you made some mistakes in your codes, you can define a variable of current weapon is 0, and a array weapon_names = [“Sword”, “Pistol”], so when player scroll down then the current weapon will be += 1 so you can easily get the weapon by $Weapons.get_node(weapon_names[current_weapon])

Thank you, I’ll have to try this! Would the array be in the player scene or would I make a resource to handle them? (I could be wrong on that)

1 Like

on player script

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.