コード例 #1
0
 public void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.CompareTag("Player"))
     {
         player.Take_Damage(damage, transform.position);
     }
 }
コード例 #2
0
    public void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.transform.CompareTag("Player"))
        {
            player.Take_Damage(100, transform.position);
        }

        if (collision.transform.CompareTag("bullet"))
        {
            Take_damage(damage);
        }
    }
コード例 #3
0
 public void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.transform.CompareTag("Player"))
     {
         player.Take_Damage(damage, transform.position);
         Destroy(this.gameObject);
     }
     if (collision.transform.CompareTag("Enemy") || collision.transform.CompareTag("Wall"))
     {
         Destroy(this.gameObject);
     }
 }
コード例 #4
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.transform.CompareTag("bullet"))
        {
            if (state.ToString() == collision.gameObject.GetComponent <player_bullet>().state.ToString()) // 충돌한 총알의 색과 몬스터의 색상이 일치하는지 판단
            {
                Take_damage(DataController.instance.gameData.Damage);
            }
        }

        if (collision.transform.CompareTag("Player"))
        {
            player.Take_Damage(damage, transform.position);
        }
    }