- Home /
Question by
Phililppikos · Jan 09 at 03:21 AM ·
setactiveactiveruntime-error
When go.SetActive(false) is used, permanently sets GO to inactive???
I posted earlier today, but the post was taken down so now I can't see the solutions :(. I have created a game object array, and am frequently changing the active state of each index.
void SlopeLooper()
{
if (ActiveCount < 3)
{
int tempobj = Random.Range(1, ActivePool.Length);
while (ActivePool[tempobj].activeSelf)
{
tempobj = Random.Range(1, ActivePool.Length);
}
ActivePool[tempobj].SetActive(true);
ActivePool[tempobj].transform.position = pos;
ActiveCount++;
recordOfSlopes++;
Debug.Log(pos);
}
}
For some reason though, after the index [N] is changed, it won't let me access the GO and set active. It just cycles through some of them, paused in world coordinates, not doing anything. Is there some special twist to GO.SetActive that I am missing? Can provide more info if needed. Here is the code that sets active state to false.
if (transform.position.x < -4.7f)
{
GameObject.FindGameObjectWithTag("SlopeManager").GetComponent<SlopeActivator>().ActiveCount--;
gameObject.SetActive(false);
}
FYI each game object is a portion of the game level floor; the game itself is a "mountain climber".
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613051437im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
SetActive(true) not working 2 Answers
Does inactive Objects eat up Performance? 1 Answer
physics.OverlapSphere colliders 1 Answer