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 /
  • Help Room /
avatar image
0
Question by amsa259 · Nov 26, 2021 at 12:49 PM · rigidbodycolliderschild object

Issue with child object collider moving through other colliders

So I'm having a bit of an issue with implementing a shield for my player. I have a shield child object on my player which has both a box collider and a rigidbody, and I have a capsule collider and a rigidbody on my parent player object as well. I'm able to detect from the enemy script whether the enemy collides with the player or shield, but as you can see, the shield's collider passes through the enemy which allows my player to collide with the enemy as well, which I obviously don't want.

When the player holds the shield button, i enable the shield's collider (as in set the gameobject to active) and don't want anything to go through the shield collider and touch the player. Removing the rigidbody on the shield fixes this issue but then collisions are only detected on the player and not the shield.

Any ideas as to why the shield collider moves through other gameobjects? (the enemy also has a capsule collider and a rigidbody and none of the colliders are set to trigger). Of course if there's a better way to implement my shield functionality all together, I'm open to that as well.

][1]

screenshot-6-min.png (313.1 kB)
Comment
Add comment · Show 5
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 MilitaryG · Nov 26, 2021 at 06:07 PM 0
Share

We really need to see some code

avatar image amsa259 MilitaryG · Nov 26, 2021 at 06:12 PM 0
Share

I don't see how this can be an issue with code, since collisions are being registered fine, the only issue is that the child object collider moves through other colliders while the parent object doesn't. Nonetheless here's how collisions are being detected in the enemy script. Both methods in Player and PlayerShield are being called fine.

void OnCollisionEnter(Collision collision){ if(collision.gameObject.name == "HeroKnight"){ collision.gameObject.GetComponent<Player>().TakeDamage(20); } if(collision.gameObject.name == "Shield"){ collision.gameObject.GetComponent<PlayerShield>().msg(); } }

avatar image MilitaryG · Nov 26, 2021 at 06:34 PM 0
Share

Are you sure that it works when you remove rigidbody or is it the other way around

avatar image amsa259 MilitaryG · Nov 26, 2021 at 06:37 PM 0
Share

yes, 100% sure the shield collider works as intended (not going through the enemy collider) when I remove rigidbody.

avatar image MilitaryG · Nov 26, 2021 at 06:58 PM 0
Share

Try reading

This

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by maewionn · Nov 27, 2021 at 04:37 AM

Well, the basic question here is: What collision detection is your rigidbody set to? If it is discrete (the normal option) things will likely clip through, depending on how fast they move. Try continous dynamic, and if that doesn't work, go for continous speculative.

You did not specify what kind of shield it is. If it is an energy bubble, maybe a distance check each frame would work (if there are not too many enemies, else it would be quite costly). If you are using navmesh agents, adding an obstacle to the player would prevent enemies from entering it. If it is a physical shield, you can do a few raycast from the enemy weapon and see if any of it hit the shield and then block the movement.

Hope I could help :)

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

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

Related Questions

Character change is not working 0 Answers

Ball passes through the floor on movement 1 Answer

Spawned objects sink through ground, when over 3 clones 0 Answers

Imported Model with Generated Colliders (Convex) problems 1 Answer

How to create chain with realistic physics 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