【发布时间】:2015-08-23 06:10:09
【问题描述】:
现在我知道这个问题已经在这个网站和许多其他网站上被问过和回答了数百次,但我找不到解释为什么计算有效,以及如何根据我的需要实际更改它。
这是我目前的功能:
//Converts X, Y from the 2D World to a Point in the Isometric Grid
public static Vector2 WorldToIsometric(float x, float y, int scale)
{
Vector2 point = new Vector2(x, y);
Vector2 iso_point = new Vector2(point.x, point.y);
float half_scale = scale / 2;
iso_point.x = point.x - (point.y * 2) + half_scale;
iso_point.y = point.x + (point.y * 2) - half_scale;
iso_point.x /= scale;
iso_point.y /= scale;
iso_point.x = Mathf.Floor (iso_point.x);
iso_point.y = Mathf.Floor (iso_point.y);
return iso_point;
}
键:
x = mouse x in world
y = mouse y in world
scale = width of isometric tile
point = mouse point in world
iso_point = mouse point on isometric grid
我希望输出的样子:
输出的实际样子:
我只是无法理解更改代码的概念,我可能在这方面花了很长时间并且喝了太多咖啡,但无论我如何更改它似乎都不像我想的那样奏效会的。
请随意链接一个详细的教程,了解它在数学上是如何工作的,但我找不到任何能真正帮助我理解如何修改代码的东西。
提前干杯
【问题讨论】: