I’m trying to display names above my panda avatars. not sure if it’s the best way of doing it but I used TextNode.
The tutorial ( http://www.panda3d.org/manual/index.php/Text_Node ) only gives an example of aspect2d but how would you go about putting the text in 3D? I tried parenting the node to my avatar but the text won’t display.
here is the example from tutorial:
text = TextNode(‘node name’)
text.setText(“Every day in every way I’m getting better and better.”)
textNodePath = aspect2d.attachNewNode(text)
with aspect 2d, the text stays in the center of my view. I changed “aspect2d” to my avatar object but the text won’t display…
any idea how to make this work? I’m new to panda3d and would appreciate any help!
It is possible to display text in the 3D-space, but wouldn’t it be nicer, if you map the 3D-coordinates of your avatar / enemy / whatever to display coordinates? That would mean: the text has everytime the same size, no matter how far the avatar is away. This should help you: Librocket over node [Solved]
update it’s position when it moves:
fint a2d the same way as above
if base.camLens.project(p3, p2):
r2d = Point3(p2, 0, p2)
a2d = aspect2d.getRelativePoint(render2d, r2d)
self.remoteNames[id].pos = a2d
I think my problem is that I’m not resetting the position correctly?
You create a new OnscreenText every frame. Create the OnscreenText at the same time you create the avatar, then every frame update the position. And your code is easier readable in the forum with Codetags.