Unity-Technologies / 2d-extras

Fun 2D Stuff that we'd like to share!
Other
1.56k stars 344 forks source link

Don’t change neighbors on runtime #197

Open jgculebras opened 4 years ago

jgculebras commented 4 years ago

Hi, I want the player to be able to break a tile during the game, all of that is implemented but the problem I have is that I don’t want the script to change the neighbors of the tile destroyed when the game is running, Is there a method that calls that functionality, should I disable the script on Start function, any ideas? Thanks in advance

ChuanXin-Unity commented 4 years ago

You will likely need to make a modification to your Tile script. The RefreshTile function probably triggers for more than one position which updates all the neighbours. You could add something like:

public override void RefreshTile(Vector3Int location, ITilemap tileMap) { if (Application.isPlaying) { tileMap.RefreshTile(location); return; } // Original RefreshTile code here }