Implementing multiple weapons to a RPG 2D game

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Deathibrylator

Hi, everyone C:
First of all, I am new to the engine and game development. I’m watching few tutorials and trying to do my own “thing”. For now I have my ideas for a game and I wanted to think and plan evertyhing deeply before coding and so on c:
RPG 2D game → so we need multiple weapons for our characters to equip. And I don’t know how to solve this problem.
For example: we have 2 classes to play: knight and mage. Each of them has diffrent animations for running, idle etc. And then comes weapons, and what approach should I take? Should I have animation of “hitting” of knight(without weapon) and then somehow attach proper weapon? or should I have animations of “knight_hitting_sword”, “knight_hitting_mace” on so on?
2nd approach seems to be the only possible for now but number of animations will be huge :c with 2 classes and 10 weapons, we need 20 animations for only one type of hitting each weapon. And then I guess it will be difficult to start animation (in script) depending on equiped weapon and i’m worried about mess in whole project.

I’m not sure if I’m clear and I’m sorry for my english.
Thank you all for any sugesstions and patience for rookie C:

For separate characters and weapon sprites I’d go for making separate animations for each weapon in an AnimationPlayer as a child of every weapon. If you name each animation the same you can call it without needing to keep track of current weapon/ animation combo

A112Studio | 2020-05-09 15:32

If you are using spreadsheet animation from spriter or cynfig, the first option might be possible. I think the second is more likely. you can save time while making the animations by making it without a weapon, and merely adding the specific weapon for each separate animation.

yes, it might get a little messy. I recommend you use a state machine for the animations. then you can have code like:

if Input.is_action_is_just_pressed():
    If weapon_state = sword:
    If weapon_state = axe:


I’m sorry if my syntax for the checking the state is incorrect, I’m not sure exactly how it is written.

hope this helps.

Millard | 2020-05-09 16:04

thank you! syntax is good enough and I will look closely to the animationPlayer becasue so far I was using only animatedSprite.
So if I understand, it’s possible to attach weapon sprite to animation of attaking in animationPlayer? I had 5 sprites for animation of attakcing and I simply added 5 position2D and changed position of sprite weapon XD but i guess is pretty bad idea xD

Deathibrylator | 2020-05-09 16:27

And first comment, yes it’s ok but then I have to be sure that animation of hitting(knight without sword e.g) and animation of rotating weapon are synchronised. And it looks pretty hard to do so :confused:

Deathibrylator | 2020-05-09 16:41

There’s also Tween node which does exactly that, just in a more controllable manner. Or change your swords xy in an animation using Bezier curves for more interesting animations.

A112Studio | 2020-05-09 16:41

I’m glad it was helpful. :slight_smile: I’m not sure about the animation player, I was confusing the animated sprite with Unity’s animation player, lol. It can be hard using more than one game engine. :slight_smile:

Millard | 2020-05-09 16:45

just looked up the animation player, looks like it’s useful for animating position and rotation of sprites by hand. I think it’s also used to animate characters with bones. I’m not sure if it could be used to attach the weapon to an animation, but it is definitely a possibility. I hope someone can answer that. :slight_smile:

Millard | 2020-05-09 16:48

wow thanks guys <3 and yeah xD i was confused with Unity’s anything xD after a while i took a chance with godot c: Soo anyway great ideas, I have to check many things out c:

Deathibrylator | 2020-05-09 17:32

It looks like there’s no best answer to this :wink: let us know the solution you went for :slight_smile:

A112Studio | 2020-05-09 17:48

Sure C: for now I’m still planning and organizing whole project c:

Deathibrylator | 2020-05-09 20:23