Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Bug 3D tile on Tilemap does not take into account GameObject rotation

Discussion in 'Editor & General Support' started by GuiTeK, Apr 5, 2023.

  1. GuiTeK

    GuiTeK

    Joined:
    Apr 28, 2017
    Posts:
    12
    Hi,

    Note: this is about GameObject (3D) tiles, not about Sprite (2D) tiles.

    It seems that the GameObject rotation of tiles set with
    Tilemap.SetTile()
    (or painted with the GameObject Brush in the editor) is not taken into account. Whatever the value of the rotation is in the prefab, it is always 0 once the tile has been added.

    Steps to reproduce:
    1. Create a new 3D URP Core project (I'm using Unity 2021.3.21f1)
    2. Add 2D Tilemap Editor (v1.0.0) and 2D Tilemap Extras (v2.2.5) packages to project
    3. Create a 2D Object > Tilemap > Rectangular
    4. Change Grid orientation to XZY
    5. Change Tilemap orientation to XZ
    6. Create 3D Object > Quad and name it "Tile"
    7. Set rotation of the Quad to 90;0;0 in the Inspector so it is flat on the Tilemap
    8. Make a prefab with the Quad
    9. Remove the Quad from the Scene
    10. Go to Window > 2D > Tile Palette
    11. Create a new Tile Palette
    12. Select "GameObject Brush" instead of "Default Brush"
    13. Click on "Cells" to unfold the UI
    14. Click on "Element 0" to unfold the UI
    15. Drag & Drop the Quad prefab named "Tile" created earlier in the "Game Object" input
    16. Click on "Paint with active brush (B)" at the top of the Tile Palette window
    17. Click on a few cells on the Tilemap
    18. Observe the Quad rotation is lost, it is not flat but it's "standing up" with a rotation of 0;0;0

    Is anyone aware of this behaviour?
     
  2. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    The Offset, Scale and Orientation settings in the GameObject Brush will take precedence over the values set in the Prefab for this particular case.

    If you set the Orientation in the GameObject Brush as shown below, the Quad will be painted as expected:
    upload_2023-4-10_13-5-37.png
     
  3. GuiTeK

    GuiTeK

    Joined:
    Apr 28, 2017
    Posts:
    12
    Hi, thank you for your answer @ChuanXin. However, how to achieve this using `SetTile()` or any programmatic way?
     
  4. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Right now, you would have to create a custom Tile script and override the StartUp method to set the rotation and scale.

    We will try and make this simpler so that you do not need to do this, and the creation of the GameObject in SetTile would use the rotation and scale directly instead (The position will still be set based on the Tile's position).