private void OnCollisionEnter(Collision col) { if (col.collider.CompareTag("Rock")) { GameObject.Instantiate(Replacement, transform.position, transform.rotation); Destroy(gameObject); foreach (var zombie in Zombies) { if (zombie == null) { continue; } ZombieScript script = zombie.GetComponent <ZombieScript>(); if (script == null) { continue; } bool toChasePlayer = false; script.GetDamage(DamageToZombies, toChasePlayer); } } }
private void OnCollisionEnter(Collision collision) { ZombieScript targetScript = collision.transform.GetComponent <ZombieScript>(); if (targetScript != null) { float dealingDamage = calculateDamage(); bool toChasePlayer = true; targetScript.GetDamage(dealingDamage, toChasePlayer); } }