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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Rotating Tiles in Tilemaps Programmatically

Discussion in '2D' started by Egregorious, Oct 9, 2021.

  1. Egregorious

    Egregorious

    Joined:
    May 31, 2016
    Posts:
    4
    I'm trying to create Tilemaps programmatically. I'm creating a new Tilemap; instantiating a new Tile; using Addressables to load in a sprite; adding the sprite to the new Tile; then using SetTile() to place that tile into the Tilemap.

    However the only way I can figure how to rotate the graphic programmatically is to work with Matrix4x4s in the Tile object. Which I am prepared to learn how to do on my own, however the Unity documentation seems to imply it shouldn't be necessary for something as seemingly simple as rotating a tile graphic.

    So am I missing a more obvious solution? How am I supposed to rotate graphics on a Tilemap programmatically?
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,954
    I think if you rotate it in the editor, then study the matrix, you'll find that's exactly how they rotate it too.
     
    Last edited: Oct 10, 2021
  3. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,323
  4. Egregorious

    Egregorious

    Joined:
    May 31, 2016
    Posts:
    4
    I'll work with the Matrix4x4s directly then, thanks for the tips!