void Impact(GameObject hitGameObject, Vector3 hitPoint, Vector3 hitNormal) { if (castersProjectileAbility != null) { //First check if it has a health component Debug.Log("Projectile Hit"); ScriptableProjectileAbility projectileAbility = castersProjectileAbility.Ability as ScriptableProjectileAbility; if (projectileAbility == null) { Debug.LogError("Projectile: ScriptableAbility is not of type ScriptableProjectileAbility"); } castersProjectileAbility.Hit(hitGameObject, projectileAbility != null ? projectileAbility.Damage : 0.0f, hitPoint, transform.forward, hitNormal); } else { CharacterBase hitCharacter = AttackAbility.GetParentCharacterBase(hitGameObject.transform); if (hitCharacter) { hitCharacter.TakeDamage(damage); } if (ImpactSound && ImpactAudioSource) { ImpactAudioSource.PlayOneShot(ImpactSound); } } if (ImpactSound) { transform.GetComponent <MeshRenderer>().enabled = false; transform.GetComponent <SphereCollider>().enabled = false; this.enabled = false; for (int i = 0; i < transform.childCount - 1; i++) { transform.GetChild(i).gameObject.SetActive(false); } Destroy(gameObject, ImpactSound.length); } else { Destroy(gameObject); } }