| | |
| | | return false;
|
| | | }
|
| | |
|
| | | public static float CalculateDistance(Vector3 start, Vector3 dest)
|
| | | {
|
| | | float _dis = float.MaxValue;
|
| | | start.y = 0;
|
| | | dest.y = 0;
|
| | | NavMesh.CalculatePath(start, dest, -1, _path);
|
| | | if (_path.corners != null && _path.corners.Length > 1)
|
| | | {
|
| | | _dis = 0;
|
| | | for (int i = 0; i < _path.corners.Length - 1; ++i)
|
| | | {
|
| | | _dis += Vector3.Distance(_path.corners[i], _path.corners[i + 1]);
|
| | | }
|
| | | }
|
| | | return _dis;
|
| | | }
|
| | |
|
| | | public static bool TryGetValidDest(Vector3 start, Vector3 dest, ref Vector3 validDest)
|
| | | {
|
| | | dest = AdjustPosition(dest);
|