Example #1
0
    private void SetMovementBounds()
    {
        // Offset bounds a little bit to avoid Players getting hit by their own Dodgeball when it bounces across the middle line.
        var    playerHitbox = player.GetComponent <CapsuleCollider2D>();
        float  xOffset      = playerHitbox.size.x / 2f;
        float  yOffset      = playerHitbox.size.y / 2f;
        Bounds teamBounds   = player.IsLeftTeam ? map.LeftTeamBounds : map.RightTeamBounds;

        bounds = Bounds.AddComponent(gameObject,
                                     teamBounds.LeftBound + xOffset, teamBounds.RightBound - xOffset,
                                     teamBounds.BottomBound + yOffset, teamBounds.TopBound - yOffset);
    }