コード例 #1
0
    private void OnCollisionEnter2D(Collision2D target)
    {
        if (target.gameObject.tag == "Enemy" || target.gameObject.tag == "Boss")
        {
            BaseEnemyBehaviour enemy = target.gameObject.GetComponent <BaseEnemyBehaviour>();
            enemy.TakeDamage(damage);

            DecreaseEnergy();
        }
    }
コード例 #2
0
    void HandleCollision(GameObject target)
    {
        if (target.tag == "Enemy" || target.tag == "Boss")
        {
            BaseEnemyBehaviour enemy = target.GetComponent <BaseEnemyBehaviour>();
            enemy.TakeDamage(1);

            if (health <= 0)
            {
                Destroy(this.gameObject);
            }
        }
    }