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 Bonkahe · Nov 21, 2013 at 07:58 PM · collisiongunzombie

Headshot Collision

Basically I've got a zombie that only is effected by headshots, however when I have a bullet or ray or w/e collide with the object it pulls the parents tag not the tag from the head, (I have a collision attached to the head bone I want to be able to tell via tag if this is the part hit) how do I get it to pull the tag of the specific bone/body part it has hit?

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
1
Best Answer

Answer by Paparakas · Nov 21, 2013 at 11:12 PM

Ok so I actually know this one since I've had some frustrating moments with it in my own project.

If the parent is a rigidbody and the children are all exclusively colliders, it will act as a compound collider. You can look that up in the documentation. It basically just means a rigidbody comprised of multiple colliders.

Either way, if you were to cast a ray to any of the colliders within the compound collider, RayCastHit hit would give you the parent (the one with the rigidbody). If you want to get the individual colliders you'd do hit.collider.

I hope this helps at least somewhat.

Comment
Add comment · Show 2 · 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 unity_-QZflx5A4SaaXg · Dec 28, 2017 at 06:24 PM 1
Share

Thanks. That really helped me! Almost 5 years on.

avatar image Bonkahe unity_-QZflx5A4SaaXg · Dec 29, 2017 at 01:02 AM 0
Share

Ironically your comment just pulled me back to this thread, and I'm about to do something similar again, which means this will help me immensely! thank you both!

avatar image
1

Answer by jotaoliveira · Nov 04, 2018 at 02:05 PM

After some research, I've found an easy way to do this without any workarounds.

When creating Colliders, use different names in each of them, as head, torso, legs, arms. Then on OnCollisionEnter method, you just had to check all of the contact points.

 void OnCollisionEnter(Collision col)
 {
     foreach (ContactPoint contact in col.contacts)
     {
         Debug.Log(contact.thisCollider.name + " hit " + contact.otherCollider.name);

         if (contact.thisCollider.name == "HitBoxHead") {
             Debug.Log("Head Shot");
         }
     }
 }
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
avatar image
0

Answer by bilo-lwabona · Nov 21, 2013 at 08:06 PM

I am not sure how one would achieve what you are trying to do in that exact way, but let me provide a close enough alternative:

You could attach a gameObject with a collider to the head portion of the mesh, where the collider is a close enough fit. Then you could assign the desired tag to the "collider gameObject" and should be able to perform the head shot detection on that.

I presume you would want to have multiple zombies, so you could create a prefab for this, meaning you would only have to set it up once and instantiate the prefab each time a zombie is created.

Hope this helps.

Cheers

Bilo

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 Bonkahe · Nov 21, 2013 at 10:54 PM 0
Share

Ok Well I did that, same problem happeneds, it just goes to the highest up on the parent list, I don't know why.

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

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

Related Questions

Allow picked up object to collide with game level GameObjects 1 Answer

C# How to have weapon pickup 1 Answer

[Javascript] My script won't work.. 1 Answer

bullet desent seem to apear (javascript) 0 Answers

Why Is My Zombie Not Colliding? 4 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