private void ApplyDamage(int damage) { if (isDead || damage <= 0) { return; } if (damageText != null) { DamageText dt = Instantiate(damageText, transform.position + textOffset, damageText.transform.rotation); dt.DoDamage(damage, textVelocity + (new Vector3(textVelocity.x * Random.value, textVelocity.y * Random.value, Random.value * textVelocity.z) * 0.5f)); } curHealth -= damage; if (targetRenderer != null) { targetRenderer.material.SetColor(colorPropertyName, damageHitColor); } if (targetIllum != null) { targetIllum.color = damageHitColor; } dmgTime = Time.time; if (curHealth <= 0) { TargetDestroyed(); } }