|
@@ -274,8 +274,9 @@ namespace GFGGame
|
|
|
if (gameObject == null) return;
|
|
|
InputEvent inputEvent = (InputEvent)context.data;
|
|
|
Vector2 pt1 = this.viewCom.GlobalToLocal(new Vector2(inputEvent.x, inputEvent.y));
|
|
|
- Vector2 pt2 = this.viewCom.GlobalToLocal(_ui.m_comSelectBox.target.position);
|
|
|
+ Vector2 pt2 = this.viewCom.GlobalToLocal(new Vector2(_ui.m_comSelectBox.target.x, _ui.m_comSelectBox.target.y));
|
|
|
Vector2 curPos = pt1 - pt2;
|
|
|
+ Debug.Log("pt1" + pt1 + " pt2:" + pt2 + " curPos:" + curPos + " lastPos:" + lastPos);
|
|
|
float angle = Vector3.Angle(lastPos, curPos); //求出两向量之间的夹角
|
|
|
Vector3 normal = Vector3.Cross(lastPos, curPos);//叉乘求出法线向量
|
|
|
angle *= Mathf.Sign(Vector3.Dot(normal, Vector3.forward)); //Mathf.Sign()求符号,Vector3.Dot()求方向,求法线向量与物体上方向向量点乘,结果为1或-1,修正旋转方向
|
|
@@ -286,6 +287,8 @@ namespace GFGGame
|
|
|
// Vector2 pt1 = this.viewCom.GlobalToLocal(new Vector2(inputEvent.x, inputEvent.y));
|
|
|
// Vector2 pt2 = this.viewCom.GlobalToLocal(_ui.m_comSelectBox.target.position);
|
|
|
float dist = Vector2.Distance(pt1, pt2);
|
|
|
+ Debug.Log("dist:" + dist);
|
|
|
+
|
|
|
float ss = dist / _startDistance;
|
|
|
float newValue = Mathf.Clamp(ss, 0.1f, 2);
|
|
|
ControllerScale(newValue, gameObject);
|