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 koss · Sep 25, 2013 at 07:50 PM · rpgmeleespherecasthit detection

Top Down RPG sword swing detection

Hello,

currently working on an top down rpg. movement, attacks, animation,.. working all really well.

But different attacks have a different attack speed. I made the hit detection with a box collider (trigger) + rigidboy (collision detection = continous) on the sword and on the player. Works really well until my attacks are too fast for the triggers =/

No i won't want the attacks to be slower ;)

Is there any alternative, detecting a swordhit? I came up to Physics.SphereCast. This is working, but I really don't know how to just to recognize the enemies in the area where the sword is swinging? Now it detects all enemys around me in the specific radius.

Has anyone did something similar? Any Solutions for it?

Thanks!

Comment
Add comment · Show 4
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 infinitypbr · Sep 25, 2013 at 08:04 PM 0
Share

It's not a solution, but an alternative, as I'm also working on a top-down RPG and had problems with colliders and triggers on the weapons. I found it was far easier to just pretend they hit.

For instance, when the enemy knight has an attack that I've labeled as "forward", it plays the animation I choose, and sends out a ray in the forward direction of the knight, the distance of which is also put in a variable. Since the knight is always "lookAt" player, the player should be right in front of him, and if close enough (the distance variable), the ray will hit, and I can do all my damage math.

This works well also because I want to have a "dodge" chance, a small chance -- increasing if the Player speed > Enemy Accuracy -- for the player ot not get damage done. Can't do that with physics.

I'm actually working on this right now, and plan on releasing an asset store package with all of this.

I'm designing it in such a way that the game builder need only list a couple variables for each weapon, attach the weapon to an enemy prefab, and all the rest is automatically done. That way it's super easy to create new enemies, super easy to create new attacks & weapons. It works with magic too -- both projectile magic and instant-hit magic -- making it super fast to set up new magic attacks with new particles (assu$$anonymous$$g that you're like me and buy particles from the asset store).

Hopefully that idea works for you -- using alternatives to physics for your hits. Once I switched, I found everything was fairly simple and works very well.

avatar image EvilWarren · Sep 26, 2013 at 02:06 PM 0
Share

If your enemies have rigid bodies attached I don't think setting collision detection to continuous will help. Continuous is used to improve detection against static meshes, so other collisions will be checked at regular rate. Try setting the sword detection mode to ContinuousDynamic and the enemies to continuous.

avatar image infinitypbr · Sep 26, 2013 at 03:53 PM 0
Share

Thanks -- I'll try that out if I get back to that method. I've switched, for now, to a fake method, simply casting a ray from the enemy to the player. It's actually better, in the end, for my purpose it turns out.

avatar image EvilWarren · Sep 26, 2013 at 05:18 PM 0
Share

If casting a ray works for you definitely stick with that: it's much faster than using continuous dynamic collision detection.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by koss · Sep 27, 2013 at 04:13 PM

Thank you guys! I made a OverlapSphere and then calculated the angle between me and and the enemy.

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

17 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 avatar image avatar image avatar image avatar image

Related Questions

Would SphereCast work for creating a detection radious larger than the one provided by Raycast? 1 Answer

Localmotion head spinning. 0 Answers

RPG Swing attack hit detection 6 Answers

Melee Combat - Collision Detection 2 Answers

Best way to detect sword hit 0 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