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
4
Question by Hector10 · Jul 27, 2016 at 07:17 PM · performancecollider2dplatformerboxcollider2dedge

EdgeCollider2D or BoxCollider2D?

Hello! Im doing this 2d platformer game and i have a question about what colliders should use. They said that boxcolliders2d is better than polygon collider and edge collider2d. But building the level with many box is getting very hard with so many corners generating unnecessary collisions. The level is also very organic with many subtle angles in platforms. Building this with boxes is not really working, and I'm with that feeling that I'm doing it wrong(newbie here btw). So i experimented the edge collider 2d and the workflow was very easy and all those ghost collisions disappeared. So i read about box collider vs edge and got worried about game performance, i profiled the game the way it is now but i don't really see any difference, actually i don't really understand about performance.

So here is my questions:

Is edge collider 2d is that worse of collision for performance compared to the box collider 2d especially when i have to use so many boxes colliders to get the level flow right? Can you explain better whats really the difference.

I also would like to know if that big difference performance in physics is more of a 3d issue workflow or really a issue to worry also in my 2d context of platforming game?

Im targeting the game to pc and hopefully a console like ps4 and xbox one. No mobile. And the project im trying to do in order to specify what kind of 2d platformers i basically aiming in a game play fast paced liked ori and the blind forest.

I know that I'm very far from my goal right now, thats why I'm would love to here more experienced advice in this collision subject. Thank you very much! Cheers!

alt text

colliders.png (54.1 kB)
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
7
Best Answer

Answer by MelvMay · Jul 28, 2016 at 08:35 AM

Is edge collider 2d is that worse of collision for performance compared to the box collider 2d especially when i have to use so many boxes colliders to get the level flow right? Can you explain better whats really the difference.

You can't just say EdgeCollider2D is better/worse performance-wise than a BoxCollider2D and make some hard rule. What you can say is that a BoxCollider2D has an AABB which when it overlaps another Collider2D AABB, all four edges need to be checked for collision. If the BoxCollider2D moves, this single AABB has to be updated (in the broad-phase).

An EdgeCollider2D has an AABB for each edge which means that only a single edge that overlaps another Collider2D AABB needs to be check for collision. If the EdgeCollider2D moves however, all AABB for each edge have to be updated (in the broad-phase).

So comparing them not moving, an EdgeCollider2D is more efficient than a BoxCollider2D at detecting collisions because potentially, only a single edge needs to be checked if a Collider2D overlaps only that edge with the added benefit that it is a continuous surface so Collider2D moving from edge-to-edge don't get stuck. It doesn't however create a closed shape (there is no 'inside' to be overlapped with) unlike the BoxCollider2D so unless you use Continuous collision detection on fast-moving Collider2D, they can potentially jump through it. The same could happen with a BoxCollider2D but they are typically larger than a single line with zero thickness! Finally, and kind of obviously, using a single component has an advantage over 10s or hundreds of individual BoxCollider2D components.

In the end, the performance difference may be negligible depending on how you use it. Just worrying about performance without there being a performance issue will lead you astray.

Comment
Add comment · Show 1 · 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 Hector10 · Jul 28, 2016 at 06:35 PM 0
Share

Thank you very much $$anonymous$$elv$$anonymous$$ay for the crystal clear explanation and the tip related about worrying performance issue without an actual issue to worry about. Both insights helped me a lot really! Thanks!

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Is it possible to have continuous collision detection with dynamic points on Edge Colliders? 0 Answers

Is there a way to apply a texture to a 2d collider? 1 Answer

Objects falling through EdgeCollider2D on the ground 0 Answers

Box Collider 2d don't collide 3 Answers

Physics2D.OverlapArea inaccurate? 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