Change Transparency Value of an Object in BGE with Keyboard In the Blender Game Engine, I have a cube as a window and have set it's Z Transparency value to .200. I would like to add Keyboard Sensor where when I hit a specific key in-game, G for example, it would change the transparency value of the cube to 1.0, like a solid wall. I would also like this to work in reverse as well, where if I hit G a second time, the transparency value would return back to it's original .200. I'm sure there's a simple solution to this that I am overlooking but any help would be appreciated, thank you!
Transparency animation


Go to first frame (1). Mouse cursor over Material/Transparency/Alpha I. The Alpha field will turn yellow.

go to last frame (21). The Alpha field should be green right now.
enter 1.0

Mouse cursor over Material/Transparency/Alpha I.The Alpha field will turn yellow.


Go back to frame 1 again.

Your material action is prepared. You can play the material action the same way as any other action. Here is one option:

Logic

Add an action actuator


setup start frame (1)
setup end frame (21)
setup action name (MaterialAction)
setup playback mode (Flipper)




Add a property 


"opaque"
type: boolean




logic to toggle opaque

Keyboard sensor -&gt; AND -&gt; Property Actuator Toggle "opaque"


logic to play animation

Property Sensor Equal "opaque" True -&gt; AND -&gt; Action Actuator




I hope it helps