Can you help me with texture on rotated tiles ?

Hi there,

I’m French (so sorry for my poor English), new to Unity and really fascinated with the possibilities with such a nice and simple IDE.

I have one problem though. I’m developing a board game (a Zombicide like for those who know it). So there are 11 scenarios and the board is different in each using 9 double-faced tiles. So I have my 18 tile textures and an xml file describing each scenario with what tiles it uses, where they are placed on my game grid, and the rotation.

I’m facing a very strange problem. I’m experimenting with a 3x3 tile grid, got classes for the gamegrid, scenarios, tiles, etc. Everything is loading fine.

I’m instantiating my tiles, and everything is perfect except on the second tiles column, the rotation is wrong. Still, the first and third columns are good…

The xml states the angle of the tile in euler (0°, 90°, 180°, 270°) and I use this angle when instantiating the tile prefab. I then apply the proper texture using :

instantiatedPrefab.GetComponent<MeshRenderer>().material.mainTexture

I thought a lot about it, checked the xml parsing (no problem), the objects in which I store the parse, and my only guess is I’m probably not aware of some 3D render thing that’d stack the rotations applied on a prefab and would be the reason of my problem… except my third column is perfect so I’m really puzzled…

Regards,
Ben

edit:
I found a workaround, except of using the retrieved angle to rotate the prefab, I use 180 minus said angle… it’s working but it doesn’t explain anything on the whereabouts of this.

After exchanging a few comments, it looks like there are 2 problems:

  1. You have wrong UV mappings. Try to use Quad instead of Cube or Plane - this should fix it, so you should see correct textures when not rotating.

  2. You’re rotating in the wrong direction. When rotating along an axis in left handed coordinate system, rotation is clockwise, but you have to look at rotating object from top (positive end of axis). So, assuming you corrected UV mappings, if you need your Tile[0,0] to look like in “Expectation” image, you have to rotate it 270 degrees.

By a coincidence, this worked for 1st and 3rd columns, because wrong UV mappings and incorrect rotations (270 instead of 90 and 90 instead of 270) negated themselves.