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 AlejandroGorgal · Dec 02, 2013 at 09:37 PM · meleespherecast

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

Ok, so I finally have my melee combat system fully functional, so now I want to improve it further. One problem Im having is that Im using a Raycast to look for a target, if the target is within the attack range we send an attack notification, straightforward stuff but my issue is that you have to be looking perfectly at the enemy in order to hit him, and since my project is a third person RPG it's often somewhat hard to aim perfectly at a moving enemy, plus it's somewhat misleading since most of the attack animations have rather large swipe range.

So, Im trying to find an alternative method that would give me a range to detect the collision with an enemy other than the straight line Raycast. I've been looking into some documentation regarding SphereCast but I can't quite understand how it works, I know I can cast a sphere in any direction I want, so I guess I would be casting on on the front of my character on the overall range of where the melee weapons land, but would any object inside the sphere be "hit" by it or is it simply casting a sphere but still relies on the straight line use to place the sphere in the world?

Comment
Add comment · Show 1
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 robertbu · Dec 02, 2013 at 09:52 PM 1
Share

It doesn't sound to me like Spherecast is what you are looking for. As an alternate simply check the distance between each enemy and the angle between your character forward and the enemy. No raycast necessary. If the enemy is within a specified distance and within a specified angle, it is a hit.

1 Reply

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

Answer by AlejandroGorgal · Dec 02, 2013 at 10:31 PM

Ok, in the remote case that somebody else out there is developing a melee system that's more accurate than the normal Raycast method I found an alternative that works very well:

http://forum.unity3d.com/threads/58574-Nice-little-melee-system-I-created-with-triggers

Basically, you add a collider to the melee weapon and use it to send the damage notifications when they enter in contact with the enemy, so it's extremely accurate.

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

16 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

Related Questions

Top Down RPG sword swing detection 1 Answer

Ai Zombie Melee Attack script. 5 Answers

NullReferenceException: Object reference not set to an instance of an object Raycast...? 1 Answer

Brawl style melee combat? 0 Answers

Tag set by animation: problem 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