Check out this new CG Masters tutorial on using a mouselook script in the BGE for FPS controls. Plus learn how to add real text in the game engine (not bitmap fonts), use Python to word wrap long strings into multiple lines, change the font resolution, and learn how to change the text in game.
Did you know that Blender’s game engine has support for real font? If we catch you still using bitmap fonts you’ll be put in stocks in the town square and have tomatoes thrown at you. This tutorial was originally just going to be a simple one on creating realtime text, but in putting together a quick demo level for it I also created a mouselook script I would like to offer everyone. For those of you unfamiliar with the term mouselook, it refers to using mouse movement to rotate the camera and look around the scene. This is typical of first person shooter type games. I should note right off the bat that you don’t need to know anything about python to do this tutorial or to use any of the scripts involved.
After we work with the mouselook script we’ll get into adding realtime text. Here we’ll deal with adding text, changing the font resolution, changing the text value in a game, and formatting the text. Formatting will include basic string operations but most notably we’ll learn how to word wrap text. Word wrapping refers to splitting long lines of text into separate lines based on line length, something that was difficult with bitmap fonts but is really simple now that real font is supported. Below is a screenshot of the scene we’ll be working with towards the end of the tutorial.