Jump to content
  • entries
  • comments
  • views

Archipelagos Remake - Unity Texture quirks



I have just spent a frustrating 4-5 days trying to figure out why movement wasn't working properly. I've reverted the project to a Windows game while I develop the mechanics. Clicking the mouse while the pointer's on a tile will move the camera to that location. Moving the pointer to the left or right edge of the screen will rotate the camera. However, I noticed that it didn't seem to be detecting the correct tile type when it came close to the sand tiles. Sometimes it was detecting water or was detecting sand a couple of squares before it should. I couldn't figure it out for days.

So I eventually ran a few tests. I suspected that it was an issue with Unity. I coloured in the corners of the texture map to Red, Green, Yellow and Black then used the Texture.GetPixel() method to return the pixel on each corner. I was expecting 0,0 to be the top left of the texture. But no. It turned out that in Unity 0,0 is the bottom left!!

Another issue with Unity was that the plane to which the texture was applied needed to be rotated by 180 degrees along the Y axis.

Once I finally had all this figured out, it was easy but this is one area that needs to be better documented.

One advantage of this coordinate system, however, is that it greatly simplified the 2D->3D and 3D->2D conversions. I moved the plane so that the bottom left sat at 0,0,0. This meant that positive X in 3D space equalled positive X in 2D space. Similarly with the Z and Y.

So now it works. Finally! Jeez!


Recommended Comments

There are no comments to display.

Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...