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 bm212 · Jan 28, 2011 at 11:24 PM · colliderhit

What is the best way to figure out which body part was hit on a rigged character?

I have a rigged character imported from blender which I'm animating. I want to shoot it, and know which bit I shot (head, body, arm, etc), so I can have it react appropriately. I shoot it by using Physics.RayCast, which works fine and reports a collision with the CharacterController which is attached to the character. This doesn't let me be any more precise with the collision though.

It seems like the solution to this is to put individual colliders on each body part (like in a ragdoll). Is there a performance cost associated with this?

Is there an alternative way of accurately determining hit location rather than using lots of colliders?

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
0

Answer by lowcrawl · Feb 13, 2011 at 10:49 PM

Here is a quick theory that you can try until someone gives a better answer. In short its the same as how you detect character damage but your dropping the script on the individual body parts.

Add in the script to print out "Hit BodyPartHere" whenever that part is being used to deduce the damage from the main character damage script.

Check the console after you have shot that body part to verify, and if it works let me know! Im aiming to accomplish the same thing but I have other tasks on my plate right now. If I get to it I will confirm this theory works and drop the code in.

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 The-Arc-Games · Nov 04, 2011 at 08:25 AM

Well the only alternative to accurately determine hit location without using lots of colliders is... using less colliders :D

Seriously: the performance cost is fortunately trivial. For example, if you can have 200 game characters with 25 bones in scene at 170 fps, if you put kinematic colliders and rigidbodies in them you need to go down to 180 game characters to reach 170 fps again.

But if performance really matters in your case, you can use three colliders, for example. One box for the spine and legs and head, and one for each arm, and use 'closestpointonbounds' after you raycast the colliders.

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 Linus · Jul 08, 2012 at 01:30 PM

My method is to have a primitive collider on the bones. Works great with animations.

You do not have to have damage reciver script or rigidbody on each bone, in fact you do not need to have rigidbody at all (Unless you want to apply physics).

As newer versions of Unity will treat all child colliders as a compound collider. Inside the raycast you can get the name of the body part (bone) that was hit through hit.collider.name and use that to apply the correct amount of damage, or apply force.

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

2 People are following this question.

avatar image avatar image

Related Questions

How to hit two object with one raycast? 2 Answers

Unity - Object hiting soon the other object 0 Answers

Raycasting and receiving hit.colliders with two cameras 0 Answers

Collision Not Responding 1 Answer

I don't know why i can't detect by ray sth. tagged, 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