Refrencing a specific collider? please help

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 :slight_smile:

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;
    }
}

Multiple ways to accomplish this. If the bomb will ever only hurt players, I’d recommend setting up appropriate collision layers. That will ensure only the player is affected.

Another method would be to check the tag or name of the colliding GameObject and act accordingly. Something like:

void OnTriggerStay(Collider PlayerCollider)
{
    if(PlayerCollider.gameObject.tag == "Player") // or .name == "Player"
        TakeBlastDamage = true;
}

You’d need to set the tag or name field appropriately, obviously.

Ohh i see that seems to work Great … Thank you very much :slight_smile: