Example #1
0
    private void OnCollisionEnter(Collision collision)
    {
        if (projectileImpact != null)
        {
            projectileImpact.Play();
        }

        //Deal damage
        if (collision.transform.GetComponentInChildren <Damage>() != null && dealDamage != null)
        {
            collision.transform.GetComponentInChildren <Damage>().TakeDamage(dealDamage.DealActualDamage());
        }

        //Deactivate process
        if (impactPrefab != null)
        {
            impactPrefab = Instantiate(impactPrefab);
            impactPrefab.transform.position = transform.position;
            impactPrefab.transform.rotation = Quaternion.Inverse(transform.rotation);
        }
        gameObject.SetActive(false);
    }