Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by Fanskapi · Feb 03, 2013 at 02:19 PM · animationmeleecombatfirst personsword

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.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by RyanZimmerman87 · Feb 09, 2013 at 03:57 PM

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:

http://www.youtube.com/watch?v=QNdGBBsC9_I

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: http://www.youtube.com/watch?v=PPbSGUPj72w

Simple Walk Animation to get you started: http://www.youtube.com/watch?v=kSDWfx6ib9k

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!

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Fanskapi · Feb 11, 2013 at 08:06 PM 0
Share

Oh no, ofcourse i'm going to use animations. :)

Obviously you got confused but what i meant was: should i check for colissions between objects; in short, letting animations take control of what i hit, or deter$$anonymous$$e if my enemies got hit by some other kind of method, like raycasting?

Anyways i already went and made some animations the day after asking this question, and made a script that checks for collissions with the weapon in question and any given enemy, it works semi-okay for what i want it to do now. I guess coupled with some short raycasts & multiple "hit boxes" per sword could make this work for accurate damaging.

Even before asking i knew how to make something like this, i'm just asking for pointers/advice on how to do it properly, concidering i'm drawing alot of attention from games like $$anonymous$$&B and Chivalry (and the numerous Source H&Ss), and thus want it to be as humanly accurate as possible.

I'll go with my "multiple hitbox-raycast" thing and see how it works out, and how accurate & playable it is.

avatar image
0

Answer by Ecofox · Feb 09, 2013 at 01:29 PM

Well I read this and it might be helpful. http://answers.unity3d.com/questions/296900/swinging-a-sword-through-code.html

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

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image sdgd · Dec 20, 2013 at 04:03 PM 0
Share

well oblivion is not a swing at all.

it's actually just trigger.

but animations makes you feel like it's a swing but it's not.

avatar image
0

Answer by TheEpicWhiteFox · Dec 20, 2013 at 04:52 PM

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 http://unity3d.com/support/resources/unity-extensions/locomotion-ik)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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

13 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How should i make sword combat ? 1 Answer

Inverse Kinematics for Sword 0 Answers

First person hack and slash weapon. 0 Answers

Best way to detect sword hit 0 Answers

Sword Combat System: Detect if player in range 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges