0
I’m developing a 2D game using the Unity 2018.3.02. I’m using Tilemap for the construction of the phase, but this Tilemap will rotate. The Tiles in Tilemap form a square, that is, the filled Tiles are those of the square border.
I have a script for my tilemap that makes this tilemap Rotacione when I click the right or left arrow keys on the keyboard:
if (Input.GetKeyDown(KeyCode.RightArrow)) transform.Rotate(0, 0, -90);
else if (Input.GetKeyDown(KeyCode.LeftArrow)) transform.Rotate(0, 0, 90);
The problem is that my tilemap rotates around the first grid Tile(0 in x and 0 in y), and I would like it to rotate around the center of the square formed by Tiles in tilemap.
I managed to make the center of the square be in position x=0,y=0, In this way, the tilemap rotates as planned. But how would I like to use the grid to get positions inside the square if I put the center in x=0,y=0, would be bad because there would be negative numbers in x and y inside the grid, so it would not be my favorite choice.
There is a way to change the center of rotation to a position other than the initial one (x = 0 and y = 0)?