I created the following tile grid in unity3d: The blue dot is the absolute center point (0,0) of both scene space and tile map.

enter image description here

Now I am trying to calculate the X/Y position of points on the tile map ( the black coordinates). The red coordinates are positions in the scene space. Every calculation I make just gives me a wrong result. Is the tile map roatated the wrong way? Any help really apreciated!

  • 3
    \$\begingroup\$ Have you considered to have your map orthogonal in scene-space and then just give the camera a diagonal rotation? That should make a lot of things much simpler. \$\endgroup\$
    – Philipp
    Feb 6, 2017 at 13:44
  • \$\begingroup\$ Thas is a genius idea! Thanks very much! Unfortunately I coded the whole level editor already so I'm gonna stick to that for a while I guess. But I think that could have safed me some time :D \$\endgroup\$
    – colosso
    Feb 6, 2017 at 18:35

1 Answer 1


Looks like you want:

tileExtents = new Vector2(0.3f, 0.17f);

scenePos.x = tileExtents.x * (tilePos.x - tilePos.y);
scenePos.y = tileExtents.y * (tilePos.x + tilePos.y);

so we can solve these equations to get the result:

scenePos.x/tileExtents.x = tilePos.x - tilePos.y
scenePos.y/tileExtents.y = tilePos.x + tilePos.y

adding the two to get x:

scenePos.x/tileExtents.x + scenePos.y/tileExtents.y = 2 * tilePos.x

tilePos.x = (scenePos.x/tileExtents.x + scenePos.y/tileExtents.y) * 0.5f;

subtracting the two to get y:

scenePos.x/tileExtents.x - scenePos.y/tileExtents.y = -2 * tilePos.y

tilePos.y = (scenePos.y/tileExtents.y - scenePos.x/tileExtents.x) * 0.5f

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .