- Home /
Question by
delorean225 · May 22, 2013 at 01:20 PM ·
toggleactiveminimapz
Toggling my minimap
I have a minimap in my game that I want to toggle on and off with Z. So far, zero luck. It doesn't turn it off, it doesn't turn it on. Here is my code:
var minimap : GameObject;
var actives : boolean;
function update(){
if (Input.KeyDown(KeyCode.Z)){
if (actives == true){
minimap.SetActive(false);
actives = true;
}
if (actives == false){
minimap.SetActive(true);
actives = true;
}
}
}
So, what am i doing wrong? Please help me!
Comment
Update with a capitol U
Get$$anonymous$$eyDown (does $$anonymous$$eyDown not give a compiler error?)
line 7 also needs to be changed to setting
actives = false;
Best Answer
Answer by Stormizin · May 22, 2013 at 07:17 PM
Try this:
if (Input.KeyDown(KeyCode.Z)){
actives = !actives;
}
It says "Expressions in statements must only be used for their side-effects."
for JavaScript you should do this as if(Input.Get$$anonymous$$eyDown("z")){ actives = !actives; }