Need help for a weapon switching system [4.2]

Godot Version

4.2

Question

Hi, sorry to bother, to give some context I have some knowledge in programming however it is the first time I am using Godot as a whole and so my knowledge regarding nodes, animation, and conventions when it comes to structure is lacking.

As it is right now, I have made a system to God of war (2018) where my player would have loadouts, each comprising of 1 Weapon + 3 abilities. Abilities can be weapon specific or general use ( magic etc… )

For a simplified rundown:

  • WeaponType is a resource with an ID, name, and a packed scene export.
  • Weapons is another resource with an ID, texture, a weaponType, and some stats.
  • Abilities are similarly resource with an ID, but they can also have an optional WeaponType

Currently, I can equip those weapons and abilities and switch between them just fine.

The issue that I have now is simply node structure and animation.

The way that I am currently going right now is in my player scene to have a WeaponManager scene. This manager listens to equip signal and spawns a weaponType.scene based on what type of weapon is currently equipped.

Each WeaponType.scene is comprised of a Sprite2D, collision box, and an animation player, and has other things like combo information ( counter, timers etc… ). So essentially anytime a weapon is equipped, the scene’s texture changes to the weapon itself ( there are currently no collision shape changes within same weapon type ), and no behavior change other than that. When collision hits an enemy, an _on_weapon_hit event is emitted with the weapon’s properties.

Now, my issue is that I am not sure whether that’s the best way to achieve my goal.
I can see potential pitfalls with the system like maybe having to trigger two animations ( one for the player, one for the weapon ) depending on the attack or ability. Or previewing the final animation/product in the editor. Or having too much communication between WeaponManager and player classes.

So my question ultimately comes down to: Am I overthinking? Is there a better way to handle this? Am I possibly going to run into issues?

TL;DR: I have a loadout switching model but unsure how to apply it with Nodes, textures, collision,

if it works, it worked

1 Like

I mean, my issue is that it does not really “work” I feel.

I can change weapons and textures just fine, however the whole process with hitboxes and animations is now very convoluted.

For example, let’s assume a random swing of a sword and an axe.

In terms of animation it would require for the sword:

  • player sprite light_swing animation
  • sword going into an arc, lingering arc hitbox

For the axe:

  • player sprite heavy_swing animation
  • hitbox let’s say being a lingering circle around you.

the way that I currently do it is ultimately have the light swing and heavy swing into the player scene animation and call it via signals from within the weapons’ scenes

and in the Axe and Sword scenes I do the weapon positions as well as hitbox changes in their own animation player.

The issue is that it’s very convoluted to see how the final product would look like in the editor preview which makes me think something is wrong with my approach.