Animating instances

Hi all,
I am creating a game with a lot of enemies on the screen. I wanted them to be instances of the same class enemy. The question is can different instances be animated differently, or they all must be the same?
I wanted to have one instance walking, another running, next - standing, etc, at the same time.

I think no. Instances share vertex data and during animation it tends to change. But instances don’t save you as much in fact i have observed that instances save you 0 of any thing except trouble. Code your game optimize later - when you need it.

Thank you, treeform. Then instances are almost of no use for me. Maybe, for animated trees and grass…

Note that there are two different uses of the word “instances” here. You can certainly have multiple instances of a class object, where each instance does its own thing completely.

What you can’t have is multiple “instances” of a NodePath, using Panda’s scene graph definition of instancing, i.e. model.instanceTo(node), doing different things. This kind of “instance” means the same node appears in multiple places in the scene graph, so naturally each instance has to show the same frame of animation.

However, there’s almost never a reason to using this level of instancing, unless you’re going for some scene-graph related special effect. If you just use the normal Actor constructor to create each of your models, they will automatically share vertices and animation tables to the greatest extent possible, and they can still be animated individually.


Thank you, David! Now I understand.