public virtual void Move() { if (_TriggerStayTSCollisions.Count > 0) { //此算法,不能解决两个阻碍墙夹角少于90的问题 TSVector AngleOnNormal = Angle;// new TSVector(Angle.x, FP.Zero, Angle.z); foreach (KeyValuePair <int, TSCollision> item in _TriggerStayTSCollisions) { //pengzhuanweizhi.transform.position = item.Value.contacts[0].point.ToVector(); //pengzhuanfaxiangliang1.transform.position = item.Value.contacts[0].point.ToVector(); //pengzhuanfaxiangliang2.transform.position = AllTSTransform.position.ToVector(); //pengzhuanfaxiangliang3.transform.position = item.Value.contacts[0].point.ToVector(); //pengzhuanfaxiangliang1.transform.rotation = TSQuaternion.LookRotation(item.Value.contacts[0].normal).ToQuaternion(); TSVector diff = item.Value.contacts[0].point - AllTSTransform.position; //pengzhuanfaxiangliang2.transform.rotation = TSQuaternion.LookRotation(diff).ToQuaternion(); //pengzhuanfaxiangliang2.transform.rotation = TSQuaternion.LookRotation(Angle).ToQuaternion(); //pengzhuanfaxiangliang1.transform.rotation = TSQuaternion.LookRotation(new TSVector(-z, FP.Zero, x)).ToQuaternion(); //pengzhuanfaxiangliang3.transform.rotation = TSQuaternion.LookRotation(AngleOnNormal).ToQuaternion(); FP AngleAndDiff = TSVector2.Angle(new TSVector2(AngleOnNormal.x, AngleOnNormal.z), new TSVector2(diff.x, diff.z)); //Debug.LogErrorFormat("夹角度{0},控制轮盘的投影{1},控制轮盘{2},Actor与碰撞点向量{3}", AngleAndDiff, AngleOnNormal.ToString(), Angle.ToString(), diff.ToString()); //Debug.LogErrorFormat("Actor====>Angle==>{0}", TSVector2.Angle(new TSVector2(Angle.x, Angle.z), new TSVector2(item.Value.contacts[0].normal.x, item.Value.contacts[0].normal.z))); if (AngleAndDiff < 90) { AngleOnNormal = TSVector.Project(AngleOnNormal, new TSVector(-item.Value.contacts[0].normal.z, FP.Zero, item.Value.contacts[0].normal.x)); //TmpAngle = AngleOnNormal;//让控制轮盘方向变成修正后的方向AngleOnNormal } else { //AngleOnNormal = TmpAngle;//new TSVector(Angle.x, FP.Zero, Angle.z); } /*** * if (diff.magnitude < (FP)0.9) { * TSVector _addTranslation3 = new TSVector(0, 0, 0); * if (diff.x < FP.Zero) _addTranslation3.x -= 1; * else if (diff.x > FP.Zero) _addTranslation3.x += 1; * if (diff.z < FP.Zero) _addTranslation3.z -= 1; * else if (diff.z > FP.Zero) _addTranslation3.z += 1; * _addTranslation3 = _addTranslation3.normalized; * AllTSTransform.position = new TSVector(item.Value.contacts[0].point.x, 0, item.Value.contacts[0].point.z) - _addTranslation3; * Debug.LogErrorFormat("修复=================================>{0},{1}", diff.ToString(), _addTranslation3.ToString()); * } ***/ } AllTSTransform.Translate(AngleOnNormal * Speed); } else { AllTSTransform.Translate(Angle * Speed); } }