C
C#2y 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
SangitOP2y ago
i have used break points and line 87 does not get read at all
Sangit
SangitOP2y ago
Saber
Saber2y ago
Do you know what SetActive does?
Sangit
SangitOP2y 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
Saber2y 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
SangitOP2y 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
TheRanger2y 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;
Want results from more Discord servers?
Add your server