Blending Online

Home

Blender Games

Vertigo [Incomplete]
The Shooting Gallery
Shadowdale
Space Assault
Transcendent Christmas Demo

CG Projects

Lamp
Rod
Asgard Ship
Another Ship
James Pond
Sword of Nibelungos
Sword of Odin
Human Head

University Projects

Library Model Walkthrough
Flash Game
VRML World

Tutorials

Building a Menu
Camera Collision
Adding Music Support
Screen Effects
Static Shadows
Using Text
Walk Cycles

Resources

Additional Font Sets
Menu Builder Template
Custom Cursor Template

Links

Random Stuff

MMORPG Characters

Using Text in the Game Engine

Displaying and manipulating text in Blender's game engine isn't quite as simple as you would expect. Here I'll outline the basic methods for adding dynamic text to your Blender games.

Each line of text will require a separate plane, so to begin with let's add a plane.


Next you'll need a font image for the text. Download the Arial font, or use an alternative if you have one ready. To create your own custom fonts in Blender from .ttf files, you can use this program.

Assign this texture to the plane using the UV editor. Next you need to map the UV coordinates of the plane to surround the "@" symbol in the upper left corner:


Your plane should now look like this (in textured view):


Alter the face settings of the plane to the following:


Now, go to the Logic Section (F4) and add a property to the plane called Text. You can set this to a string type if you only want to display some text, or an integer if you want to display a health count for example:


If all went well you should now have text displayed on the screen. It may be pointing in the wrong direction, or the letters may be rotated incorrectly. You can fix this by rotating the plane and/or rotating the UV mapping of it. If the text is mirrored the wrong way around, you may need to flip the normals of the plane.

Problems

You may find that the letters have a large amount of space between them, or are too closely packed together:


To fix this problem scale the plane in edit mode either larger or smaller. Then, once you have the desired spacing between the letters, simply scale the plane back to the correct size when you are out of edit mode.

For multiple lines of text you will need a separate plane for each line. The text can now be manipulated using logic bricks or python. For a quick demonstration if you have an integer text line, set up the following logic bricks:

Keyboard Sensor -> AND Controller -> Property Actuator ( Add | Prop: Text | Value: 5 )

This should increment the number by 5 each time you press your chosen key.

Well that's pretty much all there is to setting up text fields in the game engine. I hope this tutorial proved helpful for you.