create TextNode in aspect 3D ?

Another simple question but no simple solution have been found yet.

I want to create a text node around the head of a character/actor which contains the character’s attribute (name or status). By using a billboard effect off course.

I’ve noticed the TextNode which will be attached to the aspect2d. But haven’t found the perfect way to parent to the character in 3D world.

And i think parenting to aspect2d is the same as the OnScreenText, so why create different ways to do one purpose, without extending each capabilities. For example: use the textNode and parent it to render which have the X,Y,Z properties.

Thanks in advance.

You can simply reparent your text into the 3d space. You might want to call setTwoSided(True).

Seems that doesn’t work for me. My code will be something as simple as this:

text = TextNode('text')
text.setText("ABCabc1234567890")

textNodePath = aspect2d.attachNewNode(text)
textNodePath.setScale(0.1)

then i modify into this:

textNodePath = self.actor.attachNewNode(text)
textNodePath.setTwoSided(True)

and the text node nowhere can be seen. is there something to fix ?

Thanks for the quick response.

You might need to billboard the text.

Also, 0.1 might be too small to be seen. Try leaving the scale at 1.

David

Perfecto!!!

I have to follow both Croxis and David advice. Which is to set the billboard effect first. And yes the 0.1 is too small.

The manual doesn’t seem to have the example of this one.

Well thanks guys. I’m gonna stick with it.