Beispiel #1
0
    IEnumerator RotateCoroutine(UnityAction OnEnd)
    {
        Vector2 normalizedTarget = targetVector.normalized;
        float   delta            = Mathf.Abs(Vector2.Dot(craft.transform.up, normalizedTarget) - 1f);

        while (delta > 0.0001F)
        {
            craft.RotateCraft(targetVector);
            delta = Mathf.Abs(Vector2.Dot(craft.transform.up, normalizedTarget) - 1f);
            yield return(null);
        }
        targetVector = Vector2.zero;

        if (OnEnd != null)
        {
            OnEnd.Invoke();
        }
    }