private void OnTriggerEnter(Collider other) { if (other.CompareTag("EnemyActivator") || other.CompareTag("Projectile") || other.CompareTag("Enemy") || other.CompareTag("Arena")) { //print("Hit " + other.tag); return; } if (other.CompareTag("Player")) { if (other.isTrigger == true) { return; } //print("Projectile hit player"); Invoke(nameof(DelayedDestroy), 0.1f); PlayerHealthManager playerHM = other.gameObject.GetComponent <PlayerHealthManager>(); if (playerHM) { playerHM.RecieveDamage(damage); } } else { //print("Destroying projectile, hit " + other.name); Destroy(gameObject); } }
//Damages the player on entering the damage trigger while the enemy is charging. new private void OnTriggerEnter(Collider other) { if (stateMachine.currentState == chargeAttackState) { PlayerHealthManager playerHM = other.gameObject.GetComponent <PlayerHealthManager>(); if (playerHM != null) { PlayerVariables.playerRB.AddForce(Vector3.up * damage * 200f); playerHM.RecieveDamage(damage); } } }