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 spencerj921 · Jan 28, 2014 at 01:43 AM · 2drigidbodycollidercolliders2d-physics

is it better to make one collider for a large landmass made of many tiles, or make each of the tiles have their own colliders?

I am making a 2D platformer, and in building the levels, i need to know what has a lesser effect on the engine, to have the many smaller colliders for each tiles, or really big ones for each land i create with smaller tiles. Thank you!

Comment
Add comment · Show 1
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 Benproductions1 · Jan 28, 2014 at 09:53 AM 0
Share

A good method is to use pieces of large colliders with specifically made collision meshes

2 Replies

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

Answer by SamAgten · Jan 28, 2014 at 10:30 AM

The short answer

Less colliders means Unity has to do less checks each physics update to check for collisions. So less equals better. However, some colliders are more demanding than others: a sphere/circle collider is really fast, a mesh collider is slowish. So in some cases it is better to have more sphere colliders instead of a few mesh colliders. It is for this reason compound colliders are used instead of mesh colliders for a character (well, in this case there's a also a trade-off in precision of the collision). In other words: simple equals better. The most efficient collision systems is one that uses as few and simple colliders as possible. The size of the collider really does not matter: the math is still the same.

A bit more

If you have a large landmass consisting of different tiles, my first reflex is to think of compound colliders: use small colliders for the tiles that are isolated, and try to encapsulate the landmass in as few and simple colliders as possible. I would avoid mesh colliders unless the shape of your landmass is really complex (but you said it is tile-based so I'm guessing that is not the case).

What's also important is what every tile needs to do. It might be useful to have a collider on a tile for different reasons: to detect if the player walks on the tile to make it explode for instance!

That said, game developers are overly obsessed with making everything efficient. My advice is to start with something clean and simple that works and if you notice collision is a bottleneck, or you want to optimise before release: revise your colliders. If not: go with whatever you really understand and feels right.

Hope that helps,

Cheers,

Sam

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
1

Answer by IgorAherne · Oct 07, 2017 at 03:19 PM

The size of the collider really does not matter: the math is still the same

Not true, it's quite the opposite, - the physics is done in two stages: Broad phase (rough, inexpensive), Narrow Phase (expensive)

Broad Phase:

first of all, colliders are gathered into distinct groups, based on their location in the world. Colliders from separate groups are never checked for collisions between eachother, since we know they are far away.

Afterwards, for those in the same group, we approximated each such collider as a sphere collider (simplest to compute), and checks for intersection with sphere-approximations with the neighbors in its group.

This excludes even more candidates.

Narrow Phase:

Afterwards, entities in the same groups whose spheres intersect have to perform a full-blown triangle-to-triangle check, to detect intersection.

So, if your colliders are huge to begin with, they will end up in multiple groups at once. Not only that, but these huge colliders will also survive the sphere-approximation check, and will have to check all of their faces against all faces of of colliders in groups.

If you have a massive land, it's always better to split its collider into chunks.

In general follow the advice of SamAgten:

So in some cases it is better to have more sphere colliders instead of a few mesh colliders.

it's always better to have sphere colliders instead of mesh colliders, but of course, don't overdo it.

If your mesh collider consists of 200 triangles, 10 sphere colliders will definitelly be a gain in performance - but only if there are elements nearby with which to check for collisions (rigidbodies).

If there are no rigidbodies nearby, then as long as colliders are stationary, you shouldn't see any gain.

Cheapest to expensive:

  1. Sphere Collider

  2. AABB

  3. Capsule Collider

  4. Box Collider

  5. Mesh Collider

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

21 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

Related Questions

GameObject ignores collision while swinging from hinge joint 2D 4 Answers

How to convert Torque Stabilizer to RigidBody2D? 1 Answer

Edit tilemap cillider edit z hight 0 Answers

Colliding without gravity 2 Answers

How to make rigidbody bounce off the mouse? (2D) 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