I have created classes that inherit from Actor so that they would characterize different types of characters, each with their own properties.
For instance, character Eve is described as follows:
class Eve(Actor):
""" Input: id and root (the characters root nodepath) """
def __init__(self,id,charactersRoot):
# Must also initialize the parent class
Actor.__init__(self)
# Model and animation info
self.loadModel("Models/eve/eve")
self.loadAnims({"walk":"Models/eve/eve-walk"})
# Initializing class
#self = Actor("Models/eve/eve",{"walk":"Models/eve/eve-walk"})
self.setScale(0.7,0.7,0.7)
self.reparentTo(charactersRoot)
self.setTag("type","character")
self.setTag("char","eve")
self.setTag("id",str(id))
# Same for all characters:
self.destination = None
self.stopped = True
self.runningAnim = False
def findNodePathFromTag(self,rootNode,idTag):
""" rootNode is character or building """
nodePath = rootNode.find("=id="+str(idTag))
print "nodepath = " + str(nodePath)
return nodePath
The problem is: when I try to recover an Eve given an id tag (using nodepath.find() ) and try to manipulate its properties, Panda will give me the following error message:
AttributeError: ‘libpanda.NodePath’ object has no attribute ‘destination’
self.selectedCharacter = self.findNodePathFromTag(self.characters,self.picker.returnIdTag())
self.selectedCharacter.destination = self.picker.returnDestination()
I haven’t got what is happening. Was my Eve object thrown away and a nodepath with the same tags created in its place? How could I recover an actor or an Eve object instead of a nodepath?