What is the best way to achieve Zelda like Swordfighting?
i'm wondering how to achieve a "good" SwordfightingSystem like the one in Zelda.
I've searched for Sword Meele Tutorials or Threads but only found answered questions.
I have 2 options on my mind
First using the Overlap Function of a trigger box that would be placed around the sword and a bool that checks if we are attacking (so that we can't harm someone in idle position).
Maybe a second parameter that tells what attack we used, because the longrange cut where Link jumps deals more damage than a normal swordswing.
And the second option would be to do a raycast only a few units away from the sword and track if we hit something (most likely when the sword runs through an enemy).
Is there another option and what of those two would be the best?
How is blocking done? If i hit someone, i would directly check if he is blocking with a bool inside the enemy class and react to it with less damage and a repell animation of my character or how would i do this?
Thanks for your help!
you could use an anim notify to call a function at the moment the damage is supposed to begin and end. use those begin and end functions to control a bool, and use that bool to decide whether to trace for damage. if the bool is true, trace between current position and last position of a socket every frame to get a line that follows the socket. if you do this from several places along the blade, you can see if the sword hits something.
using the data from the trace, you can cast to an enemyPawn and get access to any enemy data you want to check, like whether they are blocking.
when you set up a blocking animation in the animGraph of your enemy, you will have a blocking blend node with a variable that controls it. check the value of this variable to know if they are blocking.
how your character reacts to blocking should depend on a lot of factors that you need to design specifically for your game. in some games, you would have complicated item stat calculations that take into account the attacker's weapon's attack points, the victim's armor's defense points, and any extra modifiers your attackers and victims can wear.
you might have enemies wearing magic items that block all melee attacks or have your character wearing magic items that cause melee attacks to be unblockable. if both of these weapon attributes exist, you need a formula that resolves these issues. this formula can be as simple as a listing all attacks in order of precedence, and defining blocking as a type of attack. if your attack ranks higher than the enemie's block, they get hit. the list of attacks can have several different blocks, varying in rank.
the way you want to rank your attacks and blocks depends on your game design, you might want special cases for random critical hits, or limit breaks, or charge attacks, but you might want special bosses that can still block those unblockable attacks, so a blockEverything attack should rank highest on the list, so it overrides any attack.
Follow this question
Once you sign in you will be able to subscribe for any updates here