Hi Blenderheads,
this Tutorial shows you how you can establish (semi-)transparent materials in the BGE.
The will appear transparent in all shading modes:
- Singletexture
- Multitexture
- GLSL
Be aware the materials will look a bit different in the various mode. This is because of different shading support.
Hint:
If you want Multitexture and GLSL appear nearly the same: switch the light’s fall-off to “Inverse Linear”.
Requirements:
- A Game Object with a Mesh (e.g. a Plane)
- The mesh should be completely unwrapped
- An image texture should be assigned to the mesh
(Please look for according unwrap tutorials if you do not know how to do that)
Semi-transparency:
-
Select the object
-
Switch to Properties
[LIST] -
Material tab
-
Add a material to the game object (if there is not any)
-
Choose a name for the material (e.g. smoke or force field)
-
Texture tab
[LIST=1] -
Add a texture
-
Give the texture a good name (e.g. smoke, force field)
-
Set Type: Image or Movie
-
I recommend to set Preview to: Both and enable Show Alpha
-
Image: Choose the image you applied to the game object earlier
-
Mapping: Change the Coordinates from Generated to UV
-
Influence: enable Color (maybe set already) and enable Alpha
-
Leave Blend with Mix untouched
-
Material tab
-
Game Settings: set Alpha Blend: Alpha Sort
-
Options: enable Face Texture and Object Color
-
Transparency: Enable Transparency
-
Transparency: enable Z Transparency
-
Transparency: set Alpha to 0.000
-
Object tab
-
Display: hover over object color ensure Alpha is 1.00 and press <I> to make a object color key frame
[/LIST]
Switch to Logic Editor
- AlwaysSensor, name: Init, No Pulses connect with
- OR controller connect with
- ActionActuator “SetColor” Mode: Play; Action: object color action; Start: 1.0; End: 1.0
[/LIST]
Do not forget to check the appearance of the materials in the various shading modes.
Hint: You can reuse the object color action for other objects. I recommend to name it like that (e.g. Fading)
Fading:
Fading is quite simple now. We just need a few additional steps.
-
go to another frame (e.g. 11)
-
Properties
[LIST] -
Object tab
-
Display: object color change Alpha to 0.0
-
Display: hover over the object color and press <I> to create a second keyframe
-
Logic Editor
-
Add any sensor to evaluate if fading should start (e.g. a Keyboard sensor) connect with
-
OR controller connect with
-
ActionActuator “Fading” Mode: Flipper, Action: object color action; Start:1.0; End:11.0
[/LIST]
Hints:
- You can choose whatever sensor you like.
- You can choose whatever controller you like.
- You can choose whatever play mode you like.
- Do not remove the previously added logic. Otherwise the material might not be visible after game start.
- You can add more object color actions to get other fading effects.
- You can set the “initial” logic to play another pose to get (semi-)transparent materials after game start. E.g. 6.0 = 50%, 11.0 = full transparent
I hope it helps
Attachments
FadeOutDemo.blend (165 KB)