Tutorial - Blender Game Engine
Right-Aligned UV Text and RTL Language SupportI'd been wondering for a while if there was a way to right align UV text in the GE, so I thought I'd give it a try. The solution I found is incredibly simple, and you'll love knowing how to do it for future projects. It also has the added benefit of RTL (Right-to-Left) language support for languages like Japanese and Hebrew.
1. Start with a regular UV Text object.
If you don't already know how to make UV Text, I encourage you to use ST150's helpful tutorial and premade text images. Also, I have several ready to use UV Text objects available for downlaod on the downloads page. (They're in Blender Library format. Follow the easy tutorial to import them.)
2. Okay, now that you have a Text object, rotate it 180 degrees so that it faces away from you.
3. Flip the normal in edit mode (W Key >> Flip Normals). When you view the text in object mode, you will see that the text is mirrored.
Notice where the origin is, though? Previously the text had generated from the left to the right. The mirrored text originates from the right! Now we just need to flip it around...
4. Flip the UV mapping. From object mode, enter UV face select mode (F Key over the 3d view). In the UV editor, select the two vertices on the left. Grab them and move them along the X axis to the opposite side of the other two vertices. Now the two selected vertices should be on the right. Select all vertices and move the box back over the @ symbol. Exit UV face select mode (F Key again). Now the letters are no longer mirrored.
This is exactly what we want for RTL language support, but if your using a LTR language (like English), it reads backward. That's easy enough to fix, though.
5. Reverse the Text. Go to the logic buttons (F9) and reverse the data in the property named "Text". For this example, I changed "www.blendenzo.com" to "moc.oznednelb.www". To use Python to reverse your text, use the short script at the end of this tutorial.
Vioala! Right-aligned text. And they said it couldn't be done...
Supplementary Material - reverseText.py ScriptTyping everything in reverse may seem a bother, so I've created a script that will reverse the text for you. Here's the code:
Right-click and "Save As" to download the .py file and connect it to your right-aligned text object. Have fun! (You could also use it on a left aligned text object if you were going for a Leonardo Davinci effect...)
Back to the tutorials index...