예제 #1
0
    void HandleHit(RaycastHit hit)
    {
        if (hit.transform.tag == "Head" && headShot)
        {
            Debug.Log("HEADSHOT");
            transform.parent.parent.parent.GetComponent <Player>().LootAmmoBox(1, 0);
            hit.transform.GetComponentInParent <HittableEntity>().TakeDamage(_damagePerHit * 3, hit);
            GameObject bloodfx = Instantiate(headShotBloodFX, hit.point, hit.transform.rotation);
            bloodfx.transform.SetParent(hit.transform.parent);
            Destroy(bloodfx, 3f);
            Destroy(hit.transform.gameObject);
        }

        HittableEntity hittedObject = hit.transform.GetComponent <HittableEntity>();

        if (hittedObject != null)
        {
            hittedObject.TakeDamage(_damagePerHit, hit);
        }
    }
예제 #2
0
 private void Awake()
 {
     m_Hittable = GetComponent <HittableEntity>();
 }