actor.loop(animation) and references

I have no real clue as to what I’m talking about, but it seems like the actor.loop method call is ignored unless the actor object is referenced.

After setting up an actor I try actor.loop(“walk1”) which works. Nothing happens if this is done in a function and the “actor” symbol is lost.

Consequently, unless I stor all actors in a list Actor.loop will be completely ignored.
If this has something to do with the GC or the namespace, how come all other aspects of the Sequence works? I can reposition and set new intervals, only Actor.loop seems to be ignored.

I would say this is expected behavior? The garbage collection will get rid of an object once it thinks you’re not using it, and the only way it can tell that is by the references to the object. Once there are no references, it’s gone.

Position and intervals operate on a node, and don’t necessarily require an Actor, whereas the animation is handled by the Actor object.

What’s the reason for not maintaining a reference to the Actor object, if you’re making use of it’s features for a node?

This is not expected at all. The pandas are there and they will animate, just not if I use the loop method. There’s no logic in that.

And no, at this moment I do not wish to maintain references to the actors. I pressumed they would be referenced from the scene graph anyway.

By the way, perhaps you could clarify that for me; actors are subclasses of nodepaths, right? When reparent an Actor instance, is the Nodepath information extracted and a new Nodepath instance inserted into the node tree? That’s overly copmlex and unintutive from an object oriented standpoint.
I just pressumed that the node tree could hold all Nodepath-subclass instancess, like an XML-tree would.

Solved it by calling Sequence.loop instead of Actor.loop.

There is, unfortunately, a nonintuitive dichotomy between C++ objects and Python objects. This is particularly a problem with regard to things that inherit from NodePath.

The fundamental problem is that a NodePath is a temporary handle to a PandaNode, and not the node itself. Actor, for historical reasons, inherits from NodePath, not from PandaNode. When you create an Actor and attach it into the scene graph, you are actually attaching the PandaNode within the Actor to the scene graph. If you then drop all the pointers to your Actor object, the Actor (and the NodePath it inherits from) will be deallocated, and the Actor will stop animating. However, the actual PandaNode object–the geometry that you see onscreen–remains, since it has been attached to the scene graph.

We don’t have a good solution to solve this problem intuitively for new Panda programmers. You just have to get used to the idea that you need to hang on to an Actor if you expect it to continue to animate.