예제 #1
0
    private IEnumerator RotateAndWalkToPosition(DetectedPlane destinationPlane, Vector3 destinationPoint)
    {
        if (destinationPlane != null && !destinationPlane.Equals(CurrentPlane))
        {
            Debug.Log("Walking to different plane!");
            GameController.FindSubpathTo(transform.position, destinationPoint, CurrentPlane, destinationPlane, ref PathSubPoints);
            if (PathSubPoints.Count > 0)
            {
                Debug.Log("Subpoints count: " + PathSubPoints.Count);
                for (int i = 0; i < PathSubPoints.Count; i += 2)
                {
                    yield return(StartCoroutine(Rotating = RotateCoroutine(GetLookRotation(PathSubPoints[i]))));

                    yield return(StartCoroutine(Walking = WalkCoroutine(GetPointIgnoredRelativeY(PathSubPoints[i]))));

                    yield return(StartCoroutine(Rotating = RotateCoroutine(GetLookRotation(PathSubPoints[i + 1]))));

                    yield return(StartCoroutine(Jumping = JumpCoroutine(PathSubPoints[i + 1], destinationPlane)));
                }
                yield return(StartCoroutine(Rotating = RotateCoroutine(GetLookRotation(destinationPoint))));

                yield return(StartCoroutine(Walking = WalkCoroutine(GetPointIgnoredRelativeY(destinationPoint))));
            }
        }
        else
        {
            yield return(StartCoroutine(Rotating = RotateCoroutine(GetLookRotation(destinationPoint))));

            yield return(StartCoroutine(Walking = WalkCoroutine(GetPointIgnoredRelativeY(destinationPoint))));
        }
    }