• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Object not turning visible when button pressed

N

Nicholander

Guest
I'm trying to make a computer version of Starfleet Battles, and I'm trying to implement the firing system. When you click the 'fire' button, the UI where you choose which weapon you want to fire appears. And when you press the button again, it dissapears; going back to movement mode.

What's happening is that when I press the fire button, the firing UI isn't appearing. However, the UI does dissapear when I start the room with it in firing mode.
Here's my code:

I have to objects here, FiringButton and PH1button. For now I'm trying to have it so that PH1button is invisible when my variable, global.if_firing, is 0, and it is visible when global.if_firing is 1.
FiringButton code: (event is 'left pressed')
Code:
if global.if_firing == 0
{
global.if_firing += 1
}

if global.if_firing == 1
{
global.if_firing -= 1
}
And here is the PH1button code: (even is 'step')
Code:
if global.if_firing == 0
{
PH1button.visible = false
}

if global.if_firing == 1
{
PH1button.visible = true
}
Both of them are in the room, and but no matter what I seem to do, PH1button doesn't come visible when I press the button. It's either that FiringButton isn't make global.if_firing to 1, or PH1button isn't doing the become visible action. When I start the room with global.if_firing to 1, the button does work and make PH1button invisible. But, of course, doesn't then make it visible when I click it again.

I just can't seem to see what's wrong. Thanks in advance for helping. :)
 
S

SyntheticStorm9

Guest
Put visible = true/ or false instead in the object you want visible.


(edit: Oh! in the left pressed code you have to put an "else" after the first code.)
 
Top