Example #1
0
    public void TakeDamage(float amount, Vector3 hitLocation, Vector3 bulletPosition)
    {
        curHealth = Mathf.Clamp(curHealth - amount, 0, maxHealth);

        zombieAI.GotAttacked();


        ParticleSystem ps = (ParticleSystem)Instantiate(bloodSplatter, hitLocation, Quaternion.identity);

        ps.transform.LookAt(bulletPosition);



        if (curHealth == 0)
        {
            hide.Hide();
            audioSource.PlayOneShot(zombieDie);
            Destroy(gameObject, 5);



            Instantiate(deathSplatter, new Vector3(hitLocation.x, 1, hitLocation.z), Quaternion.Euler(-90, 0, 0));
            Instantiate(deathSplatter, new Vector3(hitLocation.x, 0.8f, hitLocation.z), Quaternion.Euler(0, 0, 0));
            Instantiate(deathSplatter, new Vector3(hitLocation.x, 0.8f, hitLocation.z), Quaternion.Euler(0, 90, 0));
            Instantiate(deathSplatter, new Vector3(hitLocation.x, 0.8f, hitLocation.z), Quaternion.Euler(0, 180, 0));
            Instantiate(deathSplatter, new Vector3(hitLocation.x, 0.8f, hitLocation.z), Quaternion.Euler(0, 270, 0));
        }
    }