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 $$anonymous$$ · Jan 12, 2018 at 11:30 PM · collision detectioncollision2dtilepuzzle

How do I check that no collisions have a tag?

I'm trying to make a match3 game, and based on how i've implement it, every time a tile changes position, it'll try to group up with any similar colored tiles it's now adjacent to. However, this also means I need to make it ungroup from them. Is there any way to check all collisions simultaneously to determine that none have the same tag? I'd want to do something like

 private void OnCollisionExit(Collider2D[4] other)
 {
     if(other[0].gameObject.tag != this.gameObject.tag && other[1].gameObject.tag != this.gameObject.tag && other[2].gameObject.tag != this.gameObject.tag && other[3].gameObject.tag != this.gameObject.tag)
     {
          this.transform.parent = null;
     }
 }


But I'm not sure if that would work, as the standard collision functions only check one collision at a time, and I can't think of a good way to keep track that none of them have been the same type/tag as the current tile.

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
0

Answer by Buckslice · Jan 13, 2018 at 01:06 AM

Does each tile have a box collider + rigidbody and you are just letting them fall into a grid pattern and then try to find out which ones are near each other? Seems unreliable... I wouldn't even use the physics engine at all. Just store the tiles in a 2D array and each time a tile is moved do a search from each tile to see if it is apart of a match. I feel like thats how most of these kind of games would handle this.

Comment
Add comment · Show 4 · 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 $$anonymous$$ · Jan 13, 2018 at 02:14 AM 0
Share

Wouldn't that slow down the game due to the time required to search? If a match only happens when a tile moves, then i should be able to get away with seeing if the moved tile is part of a group of 3+ (i.e. if its new parent has 2 or more descendants). Seems much more efficient than running a linear search through the whole grid

avatar image Buckslice $$anonymous$$ · Jan 13, 2018 at 02:37 AM 0
Share

Ya only search from the tiles that moved, good idea. Still I wouldn't use the physics engine for this. Not sure what you are talking about with parent and descendants though... there's no real hierarchical structure here.

avatar image $$anonymous$$ Buckslice · Jan 13, 2018 at 05:35 AM 0
Share

$$anonymous$$y basic idea was that I'd set the moving tile as a child of any of its kin that it lies next to. So that all adjacent tiles of the same color are in the same family and can be easily destroyed.

Show more comments

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

73 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

Related Questions

How to set collision for an object with specific collider size? 3 Answers

2D colliders not work 1 Answer

Tile collision by sprite is not accurate with Tilemap Collider 0 Answers

OnCollisionExit2D workaround? 0 Answers

What does it mean to be "grounded"? 0 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