Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Problem with destruction of tiles

Discussion in '2D' started by Alakazam8, May 10, 2021.

  1. Alakazam8

    Alakazam8

    Joined:
    May 10, 2021
    Posts:
    2
    Hi everyone
    I'm currently working on a project for a simple game. Well, it's a 2D game based on tiles, I'm working with tiles for the first time so I obviously ran into a problem I can't find on the internet. I'm trying to do some sort of chain effect in a way that when 1 tile is destroyed every adjacent tile gets destroyed as well causing even more destruction. I managed to destroy single tiles, but I have no idea how to do it the way I intended it.
     
  2. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    Hi @Alakazam8

    You could create an array that holds data about your tiles. So tilemap would be only for visuals.

    When your tile gets damage and it runs out of health, it explodes. Which would mean that you simply remove this tile, and find the neighbor tiles (data) in range, and reduce their health too.

    You could also update tile visuals when its health changes. I've done something like that and it works pretty nicely.

    Edit. I didn't find the thread, but this has been discussed before certainly.
    I think I posted this/similar gif back then:

    20210510_exploding_tiles2.gif
     
    Last edited: May 10, 2021
    Alakazam8 likes this.
  3. Alakazam8

    Alakazam8

    Joined:
    May 10, 2021
    Posts:
    2
    Thank you a lot:)