2D Tile rotation

Hello,

I’m trying to handle orientable tiles with size greater to 1x1.

I went with the solution to use an offset and a rotation:

  • if the size (x or y) is odd, I use 0.5 / 1 / 1.5 offset. If the size is even, I simply use the center tile as the center of the object.
  • if the tile is oriented vertically, I use the rotation proprety (in “Grid selection properties” in the tile palette).

But when I try to do it programatically, I realize that there is no “offset”, “rotation” or “transform” field for TileBase.

How can I rotate a tile programatically with Unity Tilemap system ?

Thank you very much for your help

I found the solution using tilemap’s matrix transform.TRS (allowing to modify the offset and the rotation):

tilemap.SetTransformMatrix(position, Matrix4x4.TRS(ComputeOffset(orientation, position, format),
            ComputeRotation(), // quaternion
            new Vector3(1, 1, 1))); // scale