Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 VortexDEV · Feb 04, 2017 at 09:51 AM · collisioncolliderfpsbulletshooter

Bullet Damage on different Limbs

Hello, i'm currently working on a bullet damage system, where I want to have different areas on the body that have different damage modifiers, the head, the body, and the limbs, where the head has a 2.5x damage modifier, the body has a 1x modifier, and the limbs a 0.5x modifier. My problem is how do I detect which part of the body has been hit.

Currently I just have a gameobject of the target i'm using, with a script attached to it that handles the health of the target alt text

In that gameobject, I created 3 empty gameobjects, and put box colliders on each one, and gave them separate tags depending on what they were. I set the colliders to Trigger on these so that the bullet could pass through them and hit the target alt text

So, my bullet is a physical sphere, which has a script that detects collisions, and applies bullet holes at the contact point. I'm wondering when the bullet hits the target, how would I detect which part of the body was hit / which box collider did the bullet pass through. Since my bullet isn't a trigger, i've noticed that the bullet passes through the box colliders without any collisions (when using ontriggerenter). Does anyone have any ideas how I can achieve this system?

screenshot-1.png (322.6 kB)
screenshot-2.png (429.3 kB)
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 Cherno · Feb 04, 2017 at 10:25 AM 0
Share

If your bullet has a rigidbody and non-trigger collider, it should register trigger colliders. However, it's likely that it goes too fast for that because it might start in fron of the trigger in one frame and travel far enough to go completely through it for the next frame. There are workarounds to this problem, including one on the user wiki IIRC. It involves casting a ray from the last frame's position to the current one and see if the ray hit anything.

Once the colliders are registered, just compare the tag.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by JeevanjotSingh · Feb 04, 2017 at 02:24 PM

Just create script for each of your box collider (Or body part) and assign different damage value to them when the Game Object (Bullet) enter trigger.

It's like create Gameobject public variable and drag the object (Bullet) into that and assign that script into all of box colliders . Now check if triggered object tag was something and assign damage that way .

REF - https://docs.unity3d.com/ScriptReference/Collider.OnTriggerEnter.html

https://docs.unity3d.com/ScriptReference/GameObject-tag.html

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Raycast from inside an object 2 Answers

Character Controller Child Collisions 2 Answers

How can i make a raycast in my fps game? 1 Answer

2D shooter, 3d or 2d colliders? 2 Answers

How to get GameObject with its tag when ignoring Collision? 2 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