예제 #1
0
    // When something enter in enemy
    void OnTriggerEnter2D(Collider2D hitInfo)
    {
        // If enemy hitting the player
        PlayerHealthPoint playerHP = hitInfo.GetComponent <PlayerHealthPoint> ();

        if (playerHP != null)
        {
            playerHP.TakeDamage(1);
            TakeDamage(1);
        }
    }
예제 #2
0
    // When something enter in bullet
    void OnTriggerEnter2D(Collider2D hitInfo)
    {
        PlayerHealthPoint playerHP = hitInfo.GetComponent <PlayerHealthPoint> ();

        if (playerHP != null)
        {
            playerHP.TakeDamage(damage);
            Destroy(gameObject);
        }

        VacuumCleaner vc = hitInfo.GetComponent <VacuumCleaner> ();

        if (vc != null)
        {
            vc.VacuumEnemyBullet(ammoGiven);
            Destroy(gameObject);
        }
    }