Exemple #1
0
 /// <summary>
 /// Sets the reference to the manager, and assigns the bird to the foreground or background
 /// </summary>
 public void Initialize(BirdManager man, bool isForeground)
 {
     manager          = man;
     isForegroundBird = isForeground;
     isInitialized    = true;
     flyToPos         = manager.GetNewFlyPos(transform.position, transform.forward, isForegroundBird);
 }
Exemple #2
0
    void RecalculateFlyToTargetPosition()
    {
        isTurning = true;
        int i = 0;

        do
        {
            flyToPos = manager.GetNewFlyPos(transform.position, transform.forward, isForegroundBird);
            i++;
        } while (CheckIfFlyTargetIsInvalid(flyToPos - this.transform.position) && i < 20);

        if (i >= 20)    // Failsafe
        {
            Debug.Log("avoidance calculation is taking too long. This shouldn't happen often.");
            flyToPos = this.transform.position + new Vector3(0, 4f, 0); // Just try to fly up then
        }
    }