C
C#15mo ago
Sangit

gameObject does not re-enable itself in the switch statement

so i have a switch statement setup so that depending on the in-game day, a gameobject would appear/disappear however after "case 3" it does not read the rest of the code and set the game object back to true..... idk why it does that. so when its day 4, the gameobject not longer shows up.
7 Replies
Sangit
Sangit15mo ago
i have used break points and line 87 does not get read at all
Sangit
Sangit15mo ago
Saber
Saber15mo ago
Do you know what SetActive does?
Sangit
Sangit15mo ago
yeah it enables the gameoject in the scene. so that's its active in the scene? also changing to a bool does not work
Saber
Saber15mo ago
gameObject refers to the object this script is attached to correct? What do you think happens to the gameObject and this script when you SetActive(false) on day 3.
Sangit
Sangit15mo ago
ohhhhhhhhhhhhhh shit so is there a better way of doing this? cause a "if statement" would result in the same issue yeah i figured it out
TheRanger
TheRanger15mo ago
anyway try shortening ur case statement
case 1:
case 2:
case 4:
case 6:
gameObject.SetActive(true);
break;
case 3:
case 5:
case 7:
gameObject.SetActive(false);
break;
case 1:
case 2:
case 4:
case 6:
gameObject.SetActive(true);
break;
case 3:
case 5:
case 7:
gameObject.SetActive(false);
break;