Well, I’d been wondering if there was a way to right align UV text in the GE, and [a]drien asked about it around a week ago, 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 my website. (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.
Tip: You can do this all much quicker with the keyboard than with the mouse. Press “R” to rotate, then press “Y” twice to contrain rotation to the local Y-axis. Type “180” to enter the rotation directly, the press “Enter”.
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”. If you’re using Python to update your text field, you’ll need to write a short converter script to flip the text. I plan to add one to the tutorial soon. If you need it, bug me for it and I’ll write it sooner.
Tip: Don’t think too hard about it. Just type the text the way it appears already in 3D view. Look at the image of backward text above. Start with “m”, then type the letters as they appear from left to right "moc.ozne…
Vioala! Right-aligned text. And they said it couldn’t be done…
–Update–
reverseText.py Python Script
Typing everything in reverse may seem a bother, so I’ve created a script that will reverse the text for you. Here’s the code:
import GameLogic as g
def reverseText(text):
length = len(text)
newText = ""
for x in range(length):
newText += text[(length-1)-x]
return newText
own = g.getCurrentController().getOwner()
own.Text = reverseText("Fill in your text here!")
Download the .py file and connect it to your right-aligned text object. Have fun! (You could also use it on left-aligned text if you wanted to pretend you were Leonardo DaVinci.)