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. enter image description here

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

  • enter 1.0 enter image description here
  • 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:


Add an action actuator

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

enter image description here

Add a property

  • "opaque"
  • type: boolean

enter image description here

logic to toggle opaque

Keyboard sensor -> AND -> Property Actuator Toggle "opaque"

logic to play animation

Property Sensor Equal "opaque" True -> AND -> Action Actuator

enter image description here

I hope it helps


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.