DirectWaitBar value display issue

Hey,

I’m trying to display a healthbar using a DirectWaitBar. However, the display of the value is inconsistent in that sometimes when I run my game, the value of the bar shows up, and other times it does not. However, the bar always shows up. As follows is my code:

class Creep(object):
	def __init__(self, showbase, midPoints, positionInList):
		self.totalHp = 1000
		#CurrentHp that will be updated and used as value in hpBar
		self.hp = self.totalHp
		self.showbase = showbase
		self.midPoints = midPoints
		self.position = positionInList
		self.start = midPoints[0][0]
		self.creep = Actor("models/panda-model",
								{"walk": "models/panda-walk4"})
		self.creep.setPos(self.start)
		self.creep.setScale(Point3(0.005,0.005,0.005))
		self.hpBar = DirectWaitBar(text = "", value = 50)
		self.hpBar.setScale(Point3(2.5, 1, 8))
		
	#Spanws the creep and its hpBar
	def spawn(self):
		self.creep.reparentTo(self.showbase.render)
		self.hpBar.reparentTo(self.showbase.render)
	
	#Makes the hpBar follow the creep
	#
	#Tried to, instead, make it reparent to self.creep
	#rather than self.showbase.render
	#So I didn't have to constantly update its position
	#But it didn't display when I tried this
	def showHpBar(self, task):
		self.hpBar.setPos(Point3(
								self.creep.getPos()[0],
								self.creep.getPos()[1],
								self.creep.getPos()[2]+5))
		return Task.cont

These are the only places where the hpBar is called/manipulated in any way.

Thanks in advance for the help.

I’ve run into a similar issue as this. Unfortunately I was unable to fix this issue. Kind of odd how you run the same program two different times and get two different outputs. Any ideas, anyone?

Objects reparented to render follow different Z-ordering rules than objects reparented to render2d. Perhaps you’ll need to call setDepthTest(False) and setDepthWrite(False) on the wait bar to disable z-testing, or something like that.