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
1
Question by BriceGeumez · Oct 05, 2013 at 01:34 PM · collisioncompound

Compound colliders with different layers not working as expected (Layer collision matrix)

Hello Unity community,

I have a collision scenario that I thought would make sense, but apparently gives me an issue in Unity. Here is a summary:

I have one of my main game object "ActorGameObject" with a rigidbody. I placed it in layer "ActorLayer". ActorGameObject has a compound box collider (Front and Back), also marked in "ActorLayer". I have different kind of projectile. "ProjectileAGameObject" has a box collider, rigidbody and a damage script. I placed it in "ProjectileALayer". My Layer Collision Matrix has them tagged as colliding. Until now, everything works fine.

But I want to add a protective feature to my actor, a shield. The shield only stops some projectile, but not ProjectileA. So I create "ShieldGameObject" with an encompassing SphereCollider, marked with "ShieldLayer". I nest it inside ActorGameObject because I want to inherit the actor transform (visually and physically) so as to encompass it completely. In the Layer Collision Matrix, ProjectileALayer and ShieldLayer don't collide.

  • ActorGameObject (Rigibody, script, layer="ActorLayer")

  • Colliders

  • Front (BoxCollider, layer="ActorLayer")

  • Back ((BoxCollider, layer="ActorLayer")

  • ShieldGameObject (SphereCollider, script, layer="ShieldLayer")

  • ProjectileAGameObject (Rigidbody, script, BoxCollider, layer="ProjectileALayer")

It doesn't work. My ProjectileA collides with the shield. In the debugger inside ProjectileA.OnCollisionEnter(Collision collision) :

  • collision.collider is a SphereCollider

  • collision.gameObject is ActorGameObject

It looks as though the layer value, in case of collision, is inherited from the Rigidbody rather than the collider.

To solve it, I tried:

  1. Suggested in the only other thread I found acknowledging this case, add a Rigidbody marked kinetic inside ShieldGameObject. The logic behind it is to reinherit the layer value from the rigidbody. I tested it and it doesn't work (the layer value still comes from the highest level rigibody).

  2. Place the ShieldGameObject out of the ActorGameObject hierarchy. It works, but I have to synchronize the shield transform to follow the actor, every update. Also (I stopped there, because) I have to synchronize all other behaviour. The actor dies? Kill the shield as well, ... Does that seem like the way to go?

  3. Waiting for an answer, I'm also going to try this next step: move down the actor rigidbody at the Colliders level and synchronize the rigidbody transform with the actor transform. It will limit the number of synchronizing I'll have to do, but I'm afraid of side effects of modyfing the transform of a Rigidbody...

Is there a more obvious solution I don't know about? Thanks for your help.

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

0 Replies

· Add your reply
  • Sort: 

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

15 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

Related Questions

Compound and Composite Colliders and Enter/Exit Detection 0 Answers

Create a compound collider (beginner) 2 Answers

Compound collider does not trigger the parent 1 Answer

Getting child collider when collision occurs in compound object 0 Answers

How to make a perfect elastic collision. 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