Hi guys, I am trying to make the game of life using unity and C# and I need a way to check to see if multiple cubes (at least 3 cubes) are touching a single cube. I was thinking of using OnCollisionEnter but wanted to see if there was another way. I was thinking of somthing along the lines of.
private int counter = 0;
private bool createCell;
void OnCollisionEnter(Collision col)
{
if(col.gameObject.tag == "Cube")
counter++;
if(counter > 3)
createCell = true;
}
I am not sure if something like this will work and obviously I still have to make the cases were my cell dies. I am just not 100% sure if OnCollisionEnter() is the right function I want to use to check if multiple cubes are touching a single cube.