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 Binxalot · Jul 12, 2013 at 02:13 PM · collisionboxcolliderhitbox

Hit Detection Issues with multiple colliders on 1 mesh?

I've been pushing ahead on my game and ignoring a bug that I was hoping I would figure out if I just thought about it longer. I think I figured out what's causing the problem now.

I have a shooter game with a fps gun that follows the mouse which is a GUI crosshair The bullets shoot from offscreen to wherever the mouse is pointed. the bullets are unity cubes with rigid bodies and box colliders on them.

My enemies are skinned soldier models I made. Each enemy has 2 box colliders, 1 is attached to the headbone, the other is attached to the pelvis.

The problem I have is sometimes when I shoot the enemy the hit will not register. The bullet will simply ignore the enemy and hit the "back wall" which is an invisible box collider that resets the bullet's position on impact ( I reuse the same 10 bullets because the game is for mobile, I reuse the same 6 enemies over and over again too.).

I've narrowed down the problem to 1 of 2 things, and I was hoping someone here might have experienced this as well and could tell me for sure what the issue is.

  1. The problem has something to do with two or more box colliders on the enemy mesh which are touching each other, this will cause the bullet collision to not register? So if the head and torso colliders are touching (because the enemy is crouched down and the head is looking down) the bullet wont register as hitting because there's already a collision happening on the enemy mesh? What I've done is reduced the size of the head collider and this seems to have fixed the above (I think).

  2. but if I put the enemy too close to a prop that has a box collider on it the bullet impacts wont register either. So I've been moving the enemies far away from the props. and this helps too.

  3. The bullet may be going too fast.. When I reduce the speed of the bullets the hit detection issues go away for the most part, but not always.

Using the methods above I have a pretty good success rate now, not 100% because sometimes an enemy will simply just stay invincible though. I'm thinking its that when two box colliders are hitting each other a third wont register as a hit?

The box colliders on the enemy mesh both have scripts attached to them with only oncollisionenter functions in them, they check to make sure the colliding object is tagged with bullet and fire off hit(); / death(); functions in a script attached to the main enemy mesh.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Beennn · Jul 15, 2013 at 09:13 AM

This sounds like your problem:

The bullet may be going too fast.. When I reduce the speed of the bullets the hit detection issues go away for the most part, but not always.

There's a script on the wiki which will sort it out for you: DontGoThroughThings

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

Bump when crossing box colliders 1 Answer

BoxCollider2D error 1 Answer

Collision between 2 Players while playing animations 1 Answer

Know if there is Collisions on my boxCollider 1 Answer

Hit detection for Fighting Games? 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