コード例 #1
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        PlayerCombat combat = other.GetComponent <PlayerCombat>();

        if (combat != null)
        {
            combat.AddBonusDamage(duration, bonusDamage);
            Destroy(gameObject);
        }
    }
コード例 #2
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        // Check if the player hits the trigger collider on the power up
        // if it is the player apply the upgrade and destroy the powerup.
        PlayerCombat combat = other.GetComponent <PlayerCombat>();

        if (combat != null)
        {
            combat.AddBonusDamage(duration, bonusDamage);
            Destroy(gameObject);
        }
    }