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
0
Question by apd Ninja · May 07, 2011 at 07:20 PM · collision

What is the best way to script third person real-time action melee combat in C#?

So for our game we want to have third person, real-time, action melee combat, using a sword, with a crosshair. What would be the best way to script this?

A collider on the end of the sword maybe? Or a raycast/spherecast?

Game examples with this combat system would be: Darkfall Online, Risk Your Life, TERA Online, etc etc.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by superpig · May 07, 2011 at 09:16 PM

It depends on how precise you want your swordplay to be. If precision control of the sword is part of the game's design, then you definitely want a collider on the sword.

However, if your melee attacks are more simple than that, and are more 'point and shoot,' then I'd probably use Physics.OverlapSphere() or Physics.SphereCast() in the 'hittable region' just in front of the player. Use an animation event at the right place within the melee animation to trigger the actual check and knockback.

Comment
Add comment · Show 7 · 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 apd Ninja · May 07, 2011 at 10:06 PM 0
Share

Which is easier?

avatar image apd Ninja · May 07, 2011 at 10:07 PM 0
Share

Also, are there any other options I'm not considering? And which would be more multiplayer friendly?

avatar image apd Ninja · May 07, 2011 at 10:07 PM 0
Share

And, which do you think big game developers use for this type of combat? Haha.

avatar image superpig ♦♦ · May 08, 2011 at 12:20 AM 0
Share

Attaching a collider to the sword is probably easier.

There's one other option I can think of that I didn't mention, which is to create a sphere collider game object that is actually a child of the player and moves with them, flagged as a trigger; then have a script on that collider that tracks objects entering/exiting the trigger. That way, ins$$anonymous$$d of having to check for objects in front of you, you'll get notified about them by Unity.

avatar image superpig ♦♦ · May 08, 2011 at 12:21 AM 0
Share

In my game I'm using a mixture of these techniques; to my knowledge, there is no one single best option (or I would have told you so already).

Show more comments

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

No one has followed this question yet.

Related Questions

What is the best way to script third person real-time action melee combat in C#? 0 Answers

c# Adjust In-Game audio 1 Answer

C# GameObject is not detecting collision with Character Controller 2 Answers

I need help with my enemy collision. 1 Answer

A node in a childnode? 1 Answer


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