- Home /
Question by
betapowers · Jan 28, 2018 at 01:18 PM ·
getcomponentif-statements
Get any specifically tagged GameObject that has a specific value?
Hello, what I am trying to accomplish is to somehow get an object that has specific variable integers and a specific tag to somehow get components from the specific object.
Here's some code that might explain what I am trying to do:
public int SelectPointVarX0;
public int SelectPointVarX2;
public int SelectPointVarY1;
public int SelectPointVarY3;
public GameObject SelectPointObjectX0;
public GameObject SelectPointObjectX2;
public GameObject SelectPointObjectY1;
public GameObject SelectPointObjectY3;
void ActivateTile(){
GameObject[] objs;
if (ActiveObjectSet == true) {
objs = GameObject.FindGameObjectsWithTag ("Tile");
foreach (GameObject GridFloor in objs) {
SelectPointObjectY3 = GridFloor.GetComponent<GridLifeSupport> () // and has
Ynumber == SelectPointVarY3 to be a specific object;
//like if SelectPointVarY3 = 2 , then the SelectPointObjectY3 would be a specific object and if SelectPointVarY3 was another value, then would be a different object
Comment
Your answer
