private void GiveDamage() { if (canGiveDamage) { playerHealth.ApplyDamage(); canGiveDamage = false; StartCoroutine("EnableDamaging"); } }
private void OnTriggerEnter2D(Collider2D collision) { if (GameManager.Instance.PlayerhasDied == false) { if (collision.gameObject.tag.Equals("Player")) { playerHealth.ApplyDamage(); } } }
void OnTriggerEnter(Collider other) { if (other.CompareTag("Wall")) { Destroy(gameObject); } else if (other.CompareTag("Player")) { //gameObject.SendMessage("ApplyDamage", 5, SendMessageOptions.DontRequireReceiver); PlayerHealth playerHealth = other.GetComponent <PlayerHealth>(); playerHealth.ApplyDamage(5f); } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.tag == "Bullet") { Destroy(gameObject); gameController.AddScore(scoreValue); } else if (collision.tag == "Player") { playerHealth.ApplyDamage(damage); Destroy(gameObject); } }
public void InteractWith(GameObject target) { // Get target's health PlayerHealth targetHealth = target.GetComponent <PlayerHealth>(); // Check if component extracted if (targetHealth == null) { return; } // Apply damage to the target targetHealth.ApplyDamage(20f); }
void OnTriggerStay2D(Collider2D other) //Mientras estén en contacto... { PlayerHealth playerController = other.GetComponent <PlayerHealth>(); EnemyHealth enemyController = other.GetComponent <EnemyHealth>(); if (other.gameObject.tag == "Enemy") { enemyController.ApplyDamage("acid", acidToEnemy); } if (other.gameObject.tag == "Player") { playerController.ApplyDamage("acid", acidToPlayer); } }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.tag.Equals("Ground")) { Vector2 colpoint = collision.contacts[0].point; GameObject trap = Instantiate(trapPrefab, colpoint, Quaternion.identity); Destroy(this.gameObject); } if (collision.gameObject.tag.Equals("Player")) { playerHealth.ApplyDamage(); Destroy(this.gameObject); } }
private void CollideEvent(Collider2D other) { PlayerHealth player = other.GetComponent <PlayerHealth>(); if (player == null) { return; } if (Time.fixedTime < fNextHit) { return; } player.ApplyDamage(5); fNextHit = Time.fixedTime + 2.0f; }
public void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Light") { isDetected = true; } if (other.tag == "Player") { PlayerHealth playerHealth = other.GetComponent <PlayerHealth>(); playerHealth.ApplyDamage("enemy", 20f); GameObject particle = Instantiate(bloodEffect, this.transform.position, Quaternion.identity); Destroy(this.gameObject); Destroy(particle, 1f); } }
public void Hit(float damage) { health.ApplyDamage(damage); if (health.CheckDead()) { anim.SetTrigger(HurtAnimatorMapping); } else { StartCoroutine(Die()); } playerHealthSignal.Raise(); playerKicked.Raise(); }
private void OnCollisionEnter2D(Collision2D collision) { if (!dead)// && !playerNoticed) { if (collision.gameObject.tag.Equals("Player")) { playerHealth.ApplyDamage(); } else if (collision.gameObject.tag.Equals("Ground")) { sounds.PlayDeathSound(); anim.Play("ToDeath"); dead = true; this.GetComponent <Collider2D>().enabled = false; } } }
void OnTriggerEnter2D(Collider2D col) { // Otherwise if the enemy manages to shoot himself... if (col.gameObject.tag != "Enemy" && col.gameObject.tag != "Trigger" && col.gameObject.tag != "Player") { // Instantiate the explosion and destroy the rocket. OnExplode(); Destroy(gameObject); } else if (col.gameObject.tag == "Player") { // Apply Damage PlayerHealth health = col.gameObject.GetComponent <PlayerHealth>(); health.ApplyDamage(transform); // Instantiate the explosion and destroy the rocket. OnExplode(); Destroy(gameObject); } }
void OnTriggerEnter(Collider other) { if (other.tag == "Bolt") { PlayDamageSound(); playerHealth.ApplyDamage(5); //Zerstoere Schuss Destroy(other.gameObject); } if (other.tag == "Starbase") { playerHealth.Docked(); } if (other.gameObject.name == "Enemy(Clone)") { Vector3 helper = gameObject.transform.forward; other.gameObject.GetComponent <Rigidbody>().AddForce(new Vector3(helper.x * 20f, helper.y * 20f, helper.z * 20f), ForceMode.Impulse); } }