Problem with multiple gameobjects using same script.

Hi everybody i am developing a game, the game is about escaping from the jail.

My problem is that i have an script called hide. where it will register if player comes inside the area, and i have another script called Catched that has a boolean to turn true. My problem is that when i use the hide script with one game object it works but using the hide script with multiple gameobjects it only registers with the last gameobject added to the game.

using UnityEngine;
using System.Collections;
using UnityEngine.Assertions.Must;

public class Hide : MonoBehaviour {
   
    public Transform[] HideCast;

   
   

    public Catched catcher;
   

    // Use this for initialization
    void Start () {

       
    }


    public void Update()
    {
        Debug.DrawLine(gameObject.transform.position, HideCast[0].position, Color.red);
        Debug.DrawLine(gameObject.transform.position, HideCast[1].position, Color.red);
        Debug.DrawLine(HideCast[1].position, HideCast[0].position, Color.red);

       

            catcher.hider = Physics2D.Linecast(gameObject.transform.localPosition, HideCast[0].position, 1 << LayerMask.NameToLayer("Player"))
          || Physics2D.Linecast(gameObject.transform.localPosition, HideCast[1].position, 1 << LayerMask.NameToLayer("Player"))
        || Physics2D.Linecast(HideCast[1].position, HideCast[0].position, 1 << LayerMask.NameToLayer("Player"));

    }
}

Sorry for bad english
Hope you guys can help me.
Best Regards Fatih Karaman

well, it appears your ‘Hide’ script sets a boolean on the catcher.

If they are all accessing the same catcher. Then that bool is being set by every ‘hider’ in the update.

The update order is usually the order they were added (usually), so the last one added is the last one to update the ‘hider’ property on ‘catcher’. So it’s that last one who is taking precedence.

Yes it is the last one added that takes precedence.