Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Hex Grid - need help with destroying 3 or more tiles

Discussion in 'Scripting' started by Burglebutt, Feb 15, 2020.

  1. Burglebutt

    Burglebutt

    Joined:
    Jul 24, 2014
    Posts:
    51
    The mechanics for the game I want to make are like this.


    So far I have my grid, I have a way to find out which neighbors each node has. I am able to swap tiles with clicking.

    My goal is to trigger combos like in the video when I move a tile around and have it next to other tiles of the same type.

    I have it half working, if I move a jalepeno tile next to a group of other jalepeno tiles it will destroy all of the ones that are touching except the swapped tile. It just doesn't work in certain situations ><
    Hoping someone who has made a game like this before can point me in the right direction for figuring out how to handle combos correctly! Thank you.

    my bad code...
    https://gist.github.com/burglekutt/db9ad9db2258548594dedb12bb3ff159
     
  2. Yoreki

    Yoreki

    Joined:
    Apr 10, 2019
    Posts:
    2,605
    Hi, please post your code using code tags.

    If your problem is that you destroy the other tiles, but not the moved one, then you probably run the combo / destruction on the field before you applied the position change.