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
0
Question by Starleg2 · May 23, 2018 at 02:20 PM · 2dcollisioncolliderpolygon collider 2drandom gen

How do I use a 2D polygon collider to generate a correct collider for my randomly generated mesh?

Currently I am making a randomly generated 2d tile based game in which a map generator object creates a large number of chunks and then each chunk generates a square of tiles. I have the random generation(or at least part of it) but the idea of collision evades me. The object is a mesh with each tile consisting of 2 triangles but it seems like a polygon collider where I feed it the vertices is the best option since not every tile is its own gameobject and I can't just put box colliders on all of them. My question is how would I use a polygon collider to make the darker regions have collisions while the lighter regions not have collision? alt text

Since polygon colliders have one array of vertices I was wondering how the component determines what the inside of the collider is and how to use a segmented mesh with a polygon collider because at some point my random generation would lead to a chunk being split in two.

unitycollisionissue.png (217.9 kB)
Comment
Add comment · Show 4
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 Starleg2 · May 23, 2018 at 02:21 PM 0
Share

Dont' worry about the error, that is just unity freaking out about me editing setting while the game is running

avatar image KeyboardNinja27 Starleg2 · Oct 18, 2018 at 09:41 AM 0
Share

Have you found a solution to your problem? I am currently having a simmilar problem and don't see much in the documentation.

avatar image Starleg2 KeyboardNinja27 · Oct 18, 2018 at 07:11 PM 0
Share

Yeah, I did come to a solution but the answer is on a similar question. https://answers.unity.com/questions/1511762/how-to-make-a-2d-polygon-collider-from-a-mesh.html?childToView=1513286#answer-1513286 should be the link. I included the code as well. The answer involved making an array of all the edges of every tile and removing all edges that overlap using the solid mesh as a starting point thus giving only the edge edges. Then you have to order the edges then finally put the points of the edges into a polygon collider

avatar image tormentoarmagedoom · Oct 18, 2018 at 10:47 AM 0
Share

Good day.

You can make a collider for each tile. If you group all the tiles you need as a child of a parent gameobject, and detect collisions from this parent, all child colliders will act as only 1 collider.

You also have the mesh collider.

You cal aslo have a collider in each tile (so they know what tile type is), and each tile check for collision with objects/player, etc..

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

213 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 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 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 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 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 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 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 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 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 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 avatar image avatar image avatar image

Related Questions

Efficient generation of 2d polygon collider 0 Answers

Weapon System with collide detection (Helps with script pls)!!! 0 Answers

Physics2D, Box Collider physics inaccuracy? 1 Answer

How to use Physics2D.IgnoreCollision2D in Unity 5 to cancel a trigger 0 Answers

2D Collision not working! (child sprites colliders) 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