Question by
Pyr0_4_lyf3 · Jul 23, 2017 at 08:25 PM ·
c#beginnersetactive
My game objects aren't working as I expected them to.
I am making a game where there are 4 "shields" that protect a sphere. (first game, didn't want to do anything very challenging).
Here is my code
void Update () {
if (Input.GetKeyDown (KeyCode.S))
gameObject.SetActive(true);
if (Input.GetKeyDown (KeyCode.A))
gameObject.SetActive(false);
if (Input.GetKeyDown (KeyCode.D))
gameObject.SetActive(false);
if (Input.GetKeyDown (KeyCode.W))
gameObject.SetActive(false);
}
the post separated my text.
This is copy and pasted to my other 3 "shields" with the correct keys changed to match. When I press a button, the others disappear like they're supposed to, but when I press another button, the remaining one disappears, but the other one doesn't show up.
I've been working on this for a while and can't find a solution
Comment
Answer by Eddie21uk · Jul 23, 2017 at 09:11 PM
you might bemissing brackets in between the if statements?
Your answer
![](https://koobas.hobune.stream/wayback/20220612130942im_/https://answers.unity.com/themes/thub/images/avi.jpg)