My current scripts creates and modifys the location of various prefab objects as they go along the screen. One of the things I want to find out about the active object is whether it has collided with another object, and if so, to destroy itself. The problem is that every example I've found to date has no way to access the object itself to get this information.
if (Random.value > 0.9)
{
var bomberInstance = GameObject.Find("bomber");
var newBombObject = Instantiate(Resources.Load("_prefabs/bomb"), new Vector3(bomberInstance.transform.position.x, bomberInstance.transform.position.y, bomberInstance.transform.position.z), Quaternion.identity) as GameObject;
bombArray.Add(newBombObject);
}
foreach (GameObject bomb in bombArray)
{
//get bomb objects collision status here.
var newBombYAxisPosition = bomb.transform.position.y - .1f;
bomb.transform.position = new Vector3(bomb.transform.position.x, newBombYAxisPosition, bomb.transform.position.z);
}
As you can see, the examples you find online don't exactly fit very well for what I need. Do objects in unity store this information, and if so how can it be accessed? And if not, is there another way to access this information?