Commit 7b8196ca authored by 17김현학's avatar 17김현학

change fomula easily that calculate path point in Screen.

parent 9aec2d93
...@@ -161,22 +161,6 @@ public class UIManager : MonoBehaviour ...@@ -161,22 +161,6 @@ public class UIManager : MonoBehaviour
return point - canvasSize * 0.5f + middlePoint; return point - canvasSize * 0.5f + middlePoint;
} }
private Vector3 getDestVector(Vector3 ScreenVector, Vector3 RealVector)
{
ScreenVector.z = 0;
RealVector = getXYVectorfromXZVector(RealVector);
var v = square.GetDestPoint(prevSelectPathNum) - RealVector;
var k = ScreenVector.magnitude / RealVector.magnitude;
return k * v;
}
private Vector3 getVectorFromAtoB(Vector3 a, Vector3 b)
{
var ret = b - a;
return ret;
}
public Vector3 getXYVectorfromXZVector(Vector3 v) public Vector3 getXYVectorfromXZVector(Vector3 v)
{ {
return new Vector3(v.x, v.z, 0.0f); return new Vector3(v.x, v.z, 0.0f);
...@@ -189,6 +173,16 @@ public class UIManager : MonoBehaviour ...@@ -189,6 +173,16 @@ public class UIManager : MonoBehaviour
velocityslider.UpdateValuebyVelocity(square.GetPathVelocity(pathNum)); velocityslider.UpdateValuebyVelocity(square.GetPathVelocity(pathNum));
} }
private Vector3 getInnerProduct(Vector3 a, Vector3 b)
{
return new Vector3(a.x * b.x, a.y * b.y, a.z * b.z);
}
private Vector3 getRatio(Vector3 a, Vector3 b)
{
return new Vector3(a.x / b.x, a.y / b.y, 1.0f);
}
private void TryFIndPath() private void TryFIndPath()
{ {
RaycastHit hit1; RaycastHit hit1;
...@@ -211,11 +205,20 @@ public class UIManager : MonoBehaviour ...@@ -211,11 +205,20 @@ public class UIManager : MonoBehaviour
updatePathInfo(pathNum); updatePathInfo(pathNum);
var mouseClickPosition = getMouseClickPosition(hit1); var mouseClickPosition = getMouseClickPosition(hit1);
var v = getDestVector(getVectorFromAtoB(middlePoint, mouseClickPosition), getVectorFromAtoB(player.transform.position, hit2.point)); var tmp = mouseClickPosition - middlePoint;
var tmp2 = getXYVectorfromXZVector(hit2.point);
var v = square.pathList[pathNum + 1];
var k = getRatio(tmp, tmp2);
_pathUI.transform.position = mouseClickPosition + v; _pathUI.transform.position = getInnerProduct(v, k) + middlePoint;
_pathUI.SetActive(true); _pathUI.SetActive(true);
} }
else
{
_pathUI.SetActive(false);
prevSelectPathNum = -1;
sliderflag = 0;
}
} }
else else
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment