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 ina · Jan 24, 2012 at 10:00 PM · collisioncolliderlayers

Remove collider vs putting on a layer that ignores collisions

For the cases below, is there a performance difference to either removing a collider or just putting it on a layer that ignores collisions?

Case 1: You only need to remove the collider at runtime

Case 2: You need to remove the collider and add it later at runtime


Actually, I am still not sure if I understand using layers for such things - I guess the built-in functionality only makes it simple if you want to ignore script-initiated raycast (but not actually ignore collisions among objects) ?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
4
Best Answer

Answer by DoktorAce · Apr 25, 2012 at 09:17 AM

I've been doing some research about this for a project at work. I wanted to see which method was fastest. All tests were done in the exact same scenario and fashion. Please note that the values below are from my test case and does not reflect each individual method, but rather how they performed in my scenario.

alt text

Please note that if we are talking about a trigger, this best way is to handle that in its behavior. Something in the line of having a bool check in OnTriggerEnter, end never touch the collider. That would have no impact at all.


removecollider.png (46.6 kB)
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 dannyskim · Jan 24, 2012 at 11:25 PM

Can you explain your scenario a little more in depth? I would think by using the Unity provided layer collision matrix to ignore collisions would be faster, but I don't think it offers any kind of appreciable performance enhancement if you're just removing a primitive collider. Removing a complex or compound collision box would probably be much slower though, you would have to iterate through a block of colliders to get the task done.

I've used Physics.ignoreLayerCollision( int layer1, int layer 2, bool ) with great success. From my experience, when you ignore the layer collision at runtime with this method, you have to call it again or reset it yourself. The hint this in the documentation as well.

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

Ignoring collisions between a layer and a single object 0 Answers

What drawback of frequently changing of Game Object's Layer? 0 Answers

Collision functions without physical collisions 1 Answer

Layer Collision issue 1 Answer

Layers are colliding even though they are set to ignore each other 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