Very basic beginner question about class

Hello, I just have a little problem starting with Panda3d.
The following code isn’t working (aka the animation isn’t animating):

import direct.directbase.DirectStart
from direct.actor.Actor import Actor

class actorLoader():
    def __init__(self):
        character = Actor()
        character.loadModel("test")
        character.reparentTo(render)
        character.loadAnims({"win":"test"})
        character.loop("win")
s = actorLoader()
run()

I guess I just didn’t get the way the loop is telling panda
to repeat it. I’m sorry if this question is too basic… :blush:

It seems like you load the same model for the animation, “test”. Are you sure the test.egg really contains both the animation and the model? You probably would have the animation in a different file, like test_myAnim.egg and specify loadAnims({“win”:“test_myAnim”}) instead.

Thank you for your tipp, but I could make it run:

import direct.directbase.DirectStart
from direct.actor.Actor import Actor
        
class actorLoader:
    def __init__(self):
        self.character = Actor()
        self.character.loadModel("test")
        self.character.reparentTo(render)
        self.character.loadAnims({"win":"test"})
        self.character.loop("win")
s = actorLoader()

run()

But I do not quite understand why it works now… :question:
…maybe because “character” wasn’t an object so panda didn’t loop it?

I think it garbage collected the python class that had the animations stored. Animations are not stored in c++ and panda3d nodepath so it just vanished as soon as it went out of scope the class was garbage collected even before the game was started.