private void OnCollisionEnter2D(Collision2D collision)
    {
        var bullet = collision.collider.GetComponent<Bullet>();
        var skill = collision.collider.GetComponent<PlayerActiveSkill>();

        //if(this.knockBackRoutine != null) this.StopCoroutine(this.knockBackRoutine);

        if (collision.collider.CompareTag("PlayerBullet"))
        {
            if (bullet != null)
            {
                //탄환의 진행 방향으로 넉백
                this.knockbackDir = bullet.dir;
                this.knockBackRoutine = this.StartCoroutine(this.KnockbackRoutine());
                this.knockBackSpeed = bullet.knockbackSpeed;
                bullet.penetrateCnt--;
                if (bullet.penetrateCnt <= 0) Destroy(bullet.gameObject);
                this.monster.TakeBulletDamage(bullet.damage);
                Physics2D.IgnoreCollision(collision.collider, GetComponent<Collider2D>());
            }
        }
    }

 

palyerBullet이 가진 스크립트에서 관통횟수를 확인하여 해당 횟수를 감산하는 식으로 구현하면 쉽지만 한번 관통된 탄환은 몬스터와 다시 물리작용되지 않도록  Physics2D.IgnoreCollision(collision.collider, GetComponent<Collider2D>()); 해당 기능을 사용해야한다.

 

+ Recent posts