+1 vote

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 "knighthittingsword", "knighthittingmace" 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:

asked May 9 in Projects by Deathibrylator (19 points)

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

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:
        $animation_player.play("sword_hit")
    If weapon_state = axe:
        $animation_player.play("axe_hit")

etc.

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.

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

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 :/

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.

I'm glad it was helpful. :) 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. :)

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. :)

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:

It looks like there's no best answer to this ;) let us know the solution you went for :)

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

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.