How to make multiple objects animate

First off I would like to say Hi to everyone in the Panda3D comunity :stuck_out_tongue:

I just started using Panda today and I can’t find a solution to my problem.

for i in range(10):
    GameActor = Actor.Actor("models/EF_WalkAlert",{"anim1":"models/EF_WalkAlert"})
    GameActor.setScale(1,1,1)
    GameActor.reparentTo(render)
    GameActor.setPos(0,50,-10)
    GameActor.loop("anim1")

I know that this doesn’t work but I want to make every ‘GameActor’ individual. For example I have 10 guys and I want number 9 to hide. Currently it looks like they are all under the same name and I cannot change them uniquely.

Btw this code just only animates one.

I know about instancing, but from what I know about instancing from other game laguages is that it copys the exact same data from the original and you are not able to change anything to a clone.

Thanks,

Store them in a list:

GameActors = []
for i in range(10):
    GameActor = Actor.Actor("models/EF_WalkAlert",{"anim1":"models/EF_WalkAlert"})
    GameActor.setScale(1,1,1)
    GameActor.reparentTo(render)
    GameActor.setPos(0,50,-10)
    GameActor.loop("anim1")
    GameActors.append(GameActor)

GameActors[0].stop()
GameActors[4].pose("anim1", 8)

Thanks soo much pro-rsoft this was just what I was after. Now I can start making games 8) .

That does, however, raise a good observation- unlike in some facets of programming, simply setting a variable referencing one NodePath to a new NodePath value doesn’t get rid of the first- unless you explicitly remove the previously assigned node, it will continue to exist in the scene, which is why you can get away with that first loop apparently binding 10 different instances to the same name- they all exist, you’ve just lost track of all but the last! I find that, until you’re comfortable purposefully and actively doing otherwise, it’s just good practice to keep independent handles to any geometry you put in the scene for just this reason.

Yeah, but Actors are wrappers around NodePaths and aren’t PandaNodes in the scene graph - so if an Actor goes out of scope, the GeomNode is still in the scene, but it’s no longer animating.