When the boss state is active, seagulls will quickly swoosh out of the way and fly off screen, giving the boss fight the spotlight!

private void UpdateFleeingVariables()
{
    if (BossManager.instance == null || BossManager.bossState != BossManager.BossState.Active) { return; }

    activeStats.isChasingPlayer = true;
    fleeingRotatingSpeed = -1.0f; fleeingMovementSpeed = 1.2f;

    float distance = Vector2.Distance(transform.position, GameManager.s_player.transform.position);

    // If the player is too far, stop chasing and return the seagull to the pool 🏞️
    if (distance >= 200)
    {
        activeStats.isChasingPlayer = false;
        fleeingRotatingSpeed = 1.0f; fleeingMovementSpeed = 1.0f;
        ObjectPoolManager.SendObjectToPool(poolID, gameObject);
    }
}

What the Code Does:

  • activeStats.isChasingPlayer: This flag toggles the seagull’s state between chasing or not chasing the player.

  • fleeingRotatingSpeed & fleeingMovementSpeed: These values determine how quickly the seagull rotates and moves when fleeing from the player.

  • Distance Check: The seagull checks the distance to the player. If it’s within 200 units, the seagull chases the player. If it goes beyond that distance, the seagull stops chasing and returns to the pool for reuse.

Key Concept:

In this lesson, we use distance checks to control when the seagull should stop chasing the player, making the chase feel dynamic and responsive. 🔄