void CheckTrigger(Collider other) { if (((1 << other.gameObject.layer) & _playerHealthMask) != 0) { PlayerHealth playerHealth = other.GetComponent <PlayerHealth>(); if (playerHealth) { if (playerHealth.CanGetDamage) { _moving = false; _particleSystem.Stop(); _collider.enabled = false; playerHealth.AddDamage(-_damage, OwnerTransform.position); } } } if (((1 << other.gameObject.layer) & _mapMask) != 0) { if (other.gameObject.tag != "Enemy") { _moving = false; _particleSystem.Stop(); _collider.enabled = false; } } }
private void OnTriggerEnter(Collider other) { PlayerHealth playerHealth = other.GetComponent <PlayerHealth>(); if (playerHealth) { playerHealth.AddDamage(-_damage, transform.position); } }
private void OnTriggerEnter2D(Collider2D col) { if (col.CompareTag("Enemy")) { enemy = col.GetComponent <EnemyHealth>(); if (player.speedJump || player.Screwing || player.HyperJumping) { enemy.AddDamage(999); } } else if (col.CompareTag("Suelo") && player.HyperJumping) { player.HyperJumping = player.speedJump = player.hyperJumpCharged = false; playerFX.StopLoopClips(); health.AddDamage(20); } }
void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "EnergyBall" && other.GetComponent <EnergyBall>().Shooter != this.gameObject) { print(other.GetComponent <EnergyBall>().Shooter.gameObject); //Gonna Change to a less intensive method. needs to send a value as well. PlayerHP.AddDamage(EBDamage, other.GetComponent <EnergyBall>().Shooter.gameObject); //If player has invested in Life Absorb, steal HP And Or Mana if (EBHPLifeSteal > 0) { other.GetComponent <EnergyBall>().Shooter.GetComponent <PlayerHealth>().Health += (EBDamage * EBHPLifeSteal); } if (EBMPLifeSteal > 0) { other.GetComponent <EnergyBall>().Shooter.GetComponent <PlayerHealth>().Mana += (EBDamage * EBMPLifeSteal); } if (PlayerHP.Health <= 0) { print("access"); switch (other.GetComponent <EnergyBall>().Shooter.GetComponent <PlayerHealth>().PlayerNumber) { //If Game is 2 Player default: { break; } case 1: { MatchController.GetComponent <GameController>().UpdateScore(1, (1 * MatchController.GetComponent <GameController>().Score_Modifier)); break; } case 2: { MatchController.GetComponent <GameController>().UpdateScore(2, (1 * MatchController.GetComponent <GameController>().Score_Modifier)); break; } case 3: { MatchController.GetComponent <GameController>().UpdateScore(3, (1 * MatchController.GetComponent <GameController>().Score_Modifier)); break; } case 4: { MatchController.GetComponent <GameController>().UpdateScore(4, (1 * MatchController.GetComponent <GameController>().Score_Modifier)); break; } } } } }
void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Player") { PlayerHealth playerHealth = other.gameObject.GetComponent <PlayerHealth>(); playerHealth.AddDamage(damage); Destroy(gameObject); } }
void OnTriggerStay2D(Collider2D other) { if (other.tag == "Player" && nextDamage < Time.time) { PlayerHealth playerHealth = other.gameObject.GetComponent <PlayerHealth>(); playerHealth.AddDamage(damage); nextDamage = Time.time + damageRate; playerHealth.PushBack(); } }
//Used to be OnTriggerStay but switched for Marks. void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Player" && nextDamage < Time.time) { PlayerHealth thePlayerHealth = other.gameObject.GetComponent <PlayerHealth>(); thePlayerHealth.AddDamage(damage); nextDamage = Time.time + damageRate; PushBack(other.transform); } }
IEnumerator Hit(float waitTime) { yield return(new WaitForSeconds(waitTime)); _canFly = false; _animator.SetTrigger("Destroy"); if (_hitPlayerHealth) { _hitPlayerHealth.AddDamage(-20, transform.position); } Instantiate(_explosionPref, _checkPoint.position, Quaternion.identity); }
private void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Player" && nextDamage <= Time.time) { PlayerHealth playerHealth = other.gameObject.GetComponent <PlayerHealth>(); playerHealth.AddDamage(enemyDamage); nextDamage = Time.time + damageRate; //Instantiate(explostionEfffect, transform.position, Quaternion.identity); PushBack(other.transform); } }
void Update() { RaycastHit hit; Vector3 position = transform.position; bool isHit = Physics.SphereCast(position, _radius, transform.forward, out hit, _distance, _mask); if (isHit) { PlayerHealth playerHealth = hit.collider.GetComponent <PlayerHealth>(); if (playerHealth) { if (playerHealth.CanGetDamage) { playerHealth.AddDamage(-Damage, _owner.position); gameObject.SetActive(false); } } } }