Ejemplo n.º 1
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        DamDealer damageDealer = other.gameObject.GetComponent <DamDealer>();

        if (!damageDealer)
        {
            return;
        }
        ProcessHit(damageDealer);
    }
Ejemplo n.º 2
0
    private void ProcessHit(DamDealer damageDealer)
    {
        health -= damageDealer.GetDamage();
        damageDealer.Hit();

        if (health <= 0)
        {
            Die();
        }
        else
        {
            GameObject hit = Instantiate(hitVFX, transform.position, transform.rotation);
            Destroy(hit, durationOfHit);
            AudioSource.PlayClipAtPoint(hitSound, Camera.main.transform.position, hitSoundVolume);
        }
    }