Search Unity

Question Tile textures misaligned after rotation of vertices

Discussion in 'World Building' started by frey85, Jan 6, 2024.

  1. frey85

    frey85

    Joined:
    Feb 24, 2023
    Posts:
    1
    Hi all,

    I'm facing a problem that uv-textured tiles in my world do not fit together correctly when a rotation is applied to the tiles.
    I'm writing a city builder game with tiles forming a chunk mesh like in a voxel based system (verts, tris and uvs).

    The following screenshots shows road tiles where the rotated tile textures do not fit to the other tiles.
    If no rotation is applied to a tile it looks correct. So how I calculate the rotation must be wrong.





    This is my tileset atlas:



    I tested it with a rotated version of a tile which was rotated in the tileset image already. No misalignment in this case because no vertice rotation was needed. So i'm pretty sure there is something wrong with my rotation method.

    This is how I construct the mesh and how I rotate the tiles with
    RotateVerticesAroundPivot()
    :

    https://codefile.io/f/mje4ruwADA

    I hope someone can help me out :)

    Thanks!
    Frey
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,674
    Check your cutting out of the texture... you're not in the middle of the quad... even the ramp above does not look like the roadway is precisely in the middle.

    I put red dots on the sides. They aren't the same. Start there.

    nope.png
     
    frey85 likes this.