I am learing Unity and for now trying to implement a simply pathfinding alogorithm in a simply 2D isometric diamond-shaped tilemap.
Recently I learned a way how to rotate tilemap and I already have a question.
My rotation algorithm works as follows:
- I create a Dictionary
Dictionary<Vector3Int, TileBase>
for storing tiles. - Then I iterate through my tilemap and implement a 90-degrees rotation operator as
(x, y) --> (-y, x)
. And save new tiles position in a Dictionary. - Then I clear all tiles by calling
tilemap.ClearAllTiles()
- And then set tiles again from Dictionary.
f
foreach (var item in tilesPositions)
{
tilemap.SetTile(item.Key, item.Value);
}
tilemap.CompressBounds();
Honestly I am worry a little about implementation of the pathfinding. As I understand, this algorithm receive start position and end position and made some calculation for mob's to move from start to end
Let imagine I rotate my tilemap making (x, y) --> (-y, x)
for all tiles
Will this procdeure broke a pathfinding algorithm?
And most of all, is the rotation of tilemap which maded with recalculation position for all tiles the best way to do 90 degree rotation for an isometric game?