real time text using bge

i found some tutorial about real-time text using keyboard. But what if i want to use python for the same?
are there any predefined functions that can be used in bge or gamelogic to print text on the plane?

You would have to log the keys (all options on the keyboard sensor) to your “Text” property (of string type). It is a very simple implementation. You could also access the “Text” property in any script (after every hit key if you needed, by using a blank keyboard sensor) through the dot notation…


That’s the old pre-2.49 api and it wont work in 2.5. Use this instead:


If you’re using Blender 2.5, you could give bgui a shot:

Otherwise, do as Haker23 suggested with the keyboard sensor.

From the above, this is what i’ve just done…

import GameLogic


Basically I started a new scene, deleted the cube, added a ‘text’ , then added an ‘Always’ sensor and linked that to a ‘Python’ controller linked to the script.

This isn’t how i’ll use it in practice, but it was proof of concept for real time text in Blender 2.5

if you want the user to be able to type, but not use the BGUI, you can, as suggested above, use a keyboard sensor, and make it log all keys to a property. Then get this property and set the text from that.

To go further, i’m thinking that what’s just been done is mesh text, so i’m looking again at texture text.

So i’ve found these two tutorials, basically the same but ones a video, but both are for 2.49

In the video version, at 5:36 where the texture is set up, in 2.5 I went into ‘Edit’ mode, then to the ‘Object Data’ tab and then down to the ‘Display’ panel.
Next select ‘Two Side’ and ‘Text’, then change ‘Transparency’ to ‘Alpha’.

Everything else seems to be OK. When I run the game, I see a row of @ symbols instead of letters (the right amount of characters, just the wrong ones!)

Any idea why?

Just ignore this post

it’s to do with the data packing. You’re best bet is to create a new blend, or unpack to files, delete the data and try again

The man is a star! :wink:

Now I find a tutorial… after I made a quick one!

So i followed your steps and it worked, up until I moved the text object into a separate scene and added that scene using the overlay actuator. The text now appears greyscaled and pixelated. Do you know how to fix this?