Change Transparency Value of an Object in BGE with Keyboard
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