void OnTriggerEnter2D(Collider2D other) { EntityHealthController healthController = other.gameObject.GetComponent <EntityHealthController>(); if (healthController && healthController.GetType() != typeof(PlayerHealthController)) { healthController.DamageCharacter(damage); } if (other.gameObject.tag != "Player") { Destroy(this.gameObject); } }
void OnTriggerStay2D(Collider2D other) { if (other.gameObject.tag == "Player") { if (!damageOnCooldown) { hc = other.gameObject.GetComponent <EntityHealthController>(); hc.DamageCharacter(damageDealtPerTic); StartCoroutine(DamageCooldown()); if (!hurtOnCooldown) { hc.hurtSoundEffect.Play(); StartCoroutine(HurtSoundCooldown()); } } } }
public void Start() { playerHealthController = player.GetComponent<EntityHealthController>(); }
void Awake() { playerHealthController = GameController.instance.player.GetComponent<EntityHealthController>(); audioSource = GetComponent<AudioSource>(); }