3d computer animation, open source technology, software application development, IT network security, and random awesomeness!

From the Blog

Nov
12
Posted by BrianH at 8:41 pm

One of the most annoying bugs in the Blender Game Engine was coloring text.  Pre-2.48, the only way to color text was to use Vertex Painting.  Since the introduction of GLSL into the Game Engine, things have been reworked and now it’s much easier to color text objects, even those which use the same UV font texture.  For those who’ve never actually used text in the Game Engine, I’ll give you a quick and dirty introduction.

Creating text objects in the Blender Game Engine is very easy.  It’s done through the use of a bitmap font texture, UV mapped in a unique way to a plane object.  Simply put, add a plane to your scene and then add a new UV Texture map to the object through the Editing buttons.  While in Edit Mode, open a new window with the UV/Image Editor window inside.  You could change the current view too if you lack the window space to make a new one.  Select Load in the header and choose the font image you wish to use.

Note: Blender Font Textures are specially crafted to be used in Blender.  You cannot use any image as a font set.  There is specific data that’s embedded into the top of the image to define individual letters.  There are converters designed to convert TTF font’s into Blender Bitmap Font Textures, or you can download and use one of these font’s.

  Blender Font's (unknown, 775 hits)

Now that your image is loaded, arrange the UV coordinates so that they surround the @ symbol like so.  And make the following changes in your Texture Face menu (Tex, Text, Alpha).

UV/Image Editor, the Text objet's UV map.

So now that you have a fine looking letter object, let’s make some words.  Under your Logic buttons panel, add a new property.  Change it to a string type and set it’s value to what ever you like.  Congradulations, you have finished creating a word(s) in the Blender Game Engine.

Now, you’d like to change it’s color?  Easy enough.  Previously, you would have needed to use Vertex Painting to change the color of the text and you weren’t able to use the same UV font texture on multiple text objects with different color settings.  With 2.48, it’s a breeze.  Ensure you game settings are set to “Blender Multitexture Materials”.  This will use the material settings for object textures in your game.  Now, apply a new material to your text, enable Shadeless, add a new Texture (leave at default settings), and then change the Diffuse Color to what ever you like.  If you messed up and have colored blocks for your letters, reread the instruction and try again with a new material.

When you play the game, you will see that the text is working and is colored according to the material settings.  You could easily duplicate this text object and change the property settings and material settings to easily create more text objects.