so i have created a script for a bomb i have created and i wanted it to deduct the players health if they where within a sertin blast radius and to do this i used colliders and i made it so that if the player was inside the collider when the bomb exploded then it would deduct the players health this all works fine But the problem im having is because its not checking for a specific collider it seems when ever i throw any collider within the blast radius such as one of my items it will deduct the players health is their a way i can essentially mask all other colliders and say if the “Players” collider is within the bombs collider then do the rest of the script ?
Hears my code just incase anyone needs it ![]()
using UnityEngine;
using System.Collections;
public class BombDamage : MonoBehaviour {
public bool TakeBlastDamage;
public GameObject PlayerCollider;
public GameObject Trigger;
public float Timer = 4.8f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
Timer -= Time.deltaTime;
if (Timer <= 0) {
Timer = 0;
}
if (TakeBlastDamage == true && Timer <= 0) {
GameObject Player = GameObject.FindWithTag ("Player");
_Health Health = (_Health)Player.GetComponent (typeof(_Health));
Health.Health -= 25f;
Destroy (this);
Debug.Log ("BOOM :)");
}
}
/* void OnTriggerEnter(Collider other){
Debug.Log ("Within Explosive Radius");
TakeBlastDamage = true;
}*/
void OnTriggerStay(Collider PlayerCollider){
TakeBlastDamage = true;
}
void OnTriggerExit(Collider PlayerCollider){
Debug.Log ("No Longer Within Radius");
TakeBlastDamage = false;
}
}