Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 Kaemalux · Sep 17, 2015 at 10:32 PM · 2dcollidersruntimemerge

Is it possible to merge 2D colliders?

Hello! I am trying to set up a simple rogue-like game, and i am using a nice asset for random dungeon generation... The problem is that every tile is placed in the scene alone, even when building rooms and corridors, so i have a lot of adjacent tiles with single colliders. So i would like to know: is it possible to merge these colliders in a single one somehow? I don't need to have the whole dungeon walls linked with a single collider, just reduce the number of them without having one per single tile. If anyone could help me with this issue, i would really appreciate it!

Thanks in advance, Kae

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 m-9700468 · Jan 20 at 05:51 AM 0
Share

https://docs.unity3d.com/Manual/class-CompositeCollider2D.html : the colliders you want to merge has to be the children of a gameobject with this component (im late lol)

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Eric5h5 · Sep 18, 2015 at 01:53 AM

Yes, you can read all the colliders and create a combined Polygon2D collider from the others. See PolygonCollider2D in the docs, specifically pathCount and SetPath.

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 Kaemalux · Sep 18, 2015 at 09:15 AM 0
Share

Thanks Eric, great input! I am quite new to scripting, so i am asking further info to set up the process. If you could gently tell me if this is the right way-to-do i would really appreciate it: - i get the coordinates of vertex of each single tile - i list all the data in an array - i create a new polygon2D collider with all the coordinates stored Could it work? Thanks again for your help!

avatar image
-1

Answer by lassade · Sep 18, 2015 at 12:04 AM

Pick one!

  1. You cannot merge colliders. But you can use a mesh collider and them add all the dungeon walls on the mesh (procedurally generated). (Quite hard)

  2. Create script to SendMessageUpwards just to resend OnCollision and OnTrigger events, put your script that need this calls on a GameObject and make sure that all walls is a parent of this same GO.

  3. Do the same as described in 2 but using static functions, instead of SendMessageUpwards, to avoid the need of all walls been parent of the same GO.

Comment
Add comment · Show 2 · 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 Eric5h5 · Sep 18, 2015 at 01:54 AM 0
Share

You wouldn't use mesh colliders for 2D; mesh colliders are 3D.

avatar image lassade Eric5h5 · Sep 18, 2015 at 07:58 PM 0
Share

Yeah i overlooked the title and text do not mention about 2d or 3d so i assume the game was 3d. :)

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

[2D] Find nonobscured corners of 2D sprites or collision boxes? 0 Answers

Creation of Edge Colliders at Runtime 0 Answers

Problem with method Collider2D.isTouchingLayers() 4 Answers

I can't edit colliders, how do I edit them? [2D] 2 Answers

2D Collider aren't exact? 6 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