How to detect collision in C# script not attached to any game object

I have public variables which I populate through the inspector. One script is attached to a single object and the other script has a gameObject array property. Please see below:

public class GamePlayScript : MonoBehaviour {

public BallScript ballScript;
public BrickGroupsScript brickGroupsScript;


// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {

}
}

BrickGroupsScript contains an array of bricks which has a isBroken bool property. Also the above code is attached to an empty game object. How can I detect when the ball game object is in contact/collided with a brick with isBroken = true?

I’m not too clear on what your asking, but ill take a stab.

If you need to interact with environment object in the world with collision, you’ll need to have a script and probably a collider (either as a trigger or collider) attached to that object. On the script you’ll need an OnTriggerEnter or OnColliderEnter or some way to detect a collision.

If you’re trying to store the state of the brick in a single array, id suggest using a singleton. I think this is what you’re trying to do. To do that you just need to make a public static BrickGroupScript. That way you can access it from your world-object during their collision/trigger.