for i in render.getChildren():
if isinstance(i, Actor):
i.cleanup()
i.removeNode()
else:
i.removeNode()
doesnt work
for i in render.getChildren():
if isinstance(i, Actor):
i.cleanup()
i.removeNode()
else:
i.removeNode()
doesnt work
So what should I be doing?
You could find another way, such as storing the Actor objects as a tag (beware the circular references though).
So youre saying I can’t find out if an actor is an instance of an Actor class?
No, you can’t. Not only because NodePath is a C++ class, but also because NodePath is a simple wrapper - if you get a NodePath pointer from something, it may not be the same one as the all the other NodePaths that point to the same node.
Um, I can have a common parent for all actors.
I made a common parent for all actors to avoid checking if the child node is Actor or not
parent = render.attachNewNode('parent')
# add actors here, reparent to parent
for i in parent.getChildren():
i.cleanup()
i.removeNode()
this also doesnt work, i is always nodepath, not actor.
Right! Because getChildren() returns new NodePath objects, that are not necessarily the same as your Actor’s (it’ll be a different NodePath object pointing to the same PandaNode).
And also because getParent() is written in C++: on the C++ side, your Actor is just a NodePath.
Well what can be done?
Never used tags. Is it simpler than storing each Actor in a python list?
BTW, is there some reason for having Actor as Pyhton class? Or is it just not have been ported to C++ yet?