How should i properly do sword combat? (Think: M&B/Oblivion/Skyrim)

I’m talking about a 3DP/FPS game here, which means you will be aiming your swings.

If you guys have ever played any of the Mount & Blade games you’d know how it works, basically you can choose to swing your weapon, lets say it’s a normal one handed sword that we are using, from 4 different angles: Left swing, right swing, overhead swing and a stab. The same goes with blocking with weapons (unless you have a shield, which will block the area…well, where the shield is).

Now, i’ve asked a few people and they have told me to check collission with the weapon and the enemy that i happen to hit, and have the sword be a child to an animated model. I find animating time consuming and i prefer to do programming, and not to forget my animations look like hell.

You guys think i should do is this way, or try to fake it all with raycasts all over the place (depening from which angle you swing)? I’m not against doing animations, it is fun, but like i said pretty time consuming, and i wouldn’t want to waste time doing something “the wrong way”.

I’d love to hear how you guys would make it work/how games like those mentioned make them work.

I am not sure how you intend to do all these different kinds of sword attacks without any animations? Without animations you won’t be able to see the different sword attacks so it kind of defeats the purpose?

My advice is to bite the bullet and learn at least basic animation. I think the simplest way to do this is to use Animation Events (a built in Unity feature!). Meaning you create an animation for your character (I prefer to do this in Blender since it’s free and no royalties), once you have the animation you can select your desired frame within the animations progression and create an Animation Event.

You can create a function in your characters script for example “void playerAttackEvent()”. You can then very easily call this function with your desired animation frame timing. Here is a great tutorial which explains how to do this perfectly:

What are you using for your character right now? I am having trouble imagining your set up without any animations. But don’t worry I was there myself not too long ago. After learning how to do Animation Events I can’t imagine any simpler solution to this problem. You don’t even necessarily have to detect your swords collision on the enemy (depending how realistic you want the game to be). You could simply have a “if” statement within your “void playerAttackEvent()” which only does damage if the enemy is within a certain distance.

You should create a different animation for each of your desired attacks, and call different functions from your characters script for your desired affect. I believe this a nice way to solve your problem.

Here are two more videos which helped me learn how to Animate a character in Blender:

Rigging and Skinning Character:

Simple Walk Animation to get you started:

I think I may make my own tutorials pretty soon once I become a little better with this stuff. Honestly it was really hard to find good comprehensive guides on how to do the most simple things a game maker needs.

People always assume you know how to do things when really they could teach someone who knows nothing how to do it if they are good enough at explaining the process. Good luck hope this helps!

Well I read this and it might be helpful.

But that might be too basic.
As for the sword swings Mount and blade > Zelda > Oblivion.

How I would go around this is by using both solutions.
Animation cannot be avoided nor can collision detection when it comes to realism.

First of all, you should make an animation for each of your swing directions and types; converting them all to animation events.

Next,you detect player input of “melee” then set a state of “damage inflict” on the blade which detects collisions between the blade and the target, causing damage on contact (and momentum if you’d like).

Then, use Unity’s Locomotion system (which comes with a tutorial on how to set it up Locomotion System | Animation Tools | Unity Asset Store)to influence the swing’s direction towards the target.

Afterwards, after the swing takes place, remember to disable “damage inflict” and to end the combo/swing.