Finding animation properties before loading the Actor?

Is there a way to determine properties of animation before it is loaded into Actor (i.e. before myActor.loadAnims({‘AnimName’:‘AnimPath’}))? I mean such properties as animation length in frames, playrate and so on.

Hmm, it would be tricky to do this programmatically, but possible–but this would mean basically re-doing all of the work that is already done for you by the Actor code. Unless you’re willing to settle for simply examining the egg file by hand? Not sure what your intentions are.


I see. Anyway, I made a workaround for this task.

My intentions were following:
Since my laptop is very slow with many animated actors, I will use lots of instances of few unique actors (I described it before in another thread). Now I am coding automatic “unique actor generator” for every animation of an actor (these unique actors will be instanced by NPCs). I will provide this “unique actor generator” with the the animation and the number of unique actors I want to create for this animation. Such approach makes it easy to control the number of unique actors on screen (maybe, it will be controlled by the code even, then the game will be able to adjust its own performance automatically).

If I understand you correctly, you want each “unique actor generator” to contain only one animation (or perhaps some small number of animations).

In that case, could you not simply create each animation, or perhaps set of animations, as a separate version of the model, with only those animations?

To clarify, why not, when exporting to egg, have your exporter export only one animation (or again a small set of animations), and name or place your files appropriately such that they do not overwrite each other?

You might then have “old_lady-walk.egg”, “old_lady-stand.egg”, etc. each as a combined model-and-animation file, or, if your exporter doesn’t offer that option, a set along the lines of “old_lady-walk-model.egg” + “old_lady-walk-anim.egg”, etc.

I have to have dozens of animated models on screen, and most of them will do the same actions with the same animation (40% of them are just standing and looping “idle” animation, another 40% are walking somewhere with “walk” animation, and only 20% are doing something else).
If each of these actors is different actor with its own animation reparented to its parent node with “actor.reparentTo(parent)” then each of them will be animated by Panda separately. I will have dozens of unique actors on screen, and the overall performance will be very low.
Instead I will create several unique actors and instance them. So, I will have a couple of “walk” actors, a couple of “idle” actors, and so on. The dozens of NPCs on screen will have one of these actors instanced and displayed (depending on their current action) by “actor.instanceTo(parent)”. Then the overall performance will be much higher.
I tested it a little bit, and I can have 50 unique actors on screen with 10 fps, and 50 instances of the same actor with 170 fps. Of course, in actual game the difference in performance won’t be that big, but still, the player will gain 10-20 fps.
After tweaking it carefully, the visual difference won’t be too striking either.

That’s more or less what I thought that you intended, I believe.

However, I suspect that you might have thought that I meant creating each separate NPC as a separate file, and more, creating each of its animations as a separate file.

Instead, what I’m suggesting is this:

Let’s say that you have two types of NPC, cats and dogs. Cats have the animations “meow” and “scratch”. Dogs have the animations “bark” and “pant”.

Let’s say that you want to have ten cats and ten dogs on-screen, half of each of which will be performing one of their animations, and half of which will be doing the other.

I’m suggesting that you create “cat-meow.egg”, “cat-scratch.egg”, “dog-bark.egg” and “dog-pant.egg”, each a complete actor, and then have five instances each of cat-meow, cat-scratch, dog-bark and dog-pant.

If you want a cat to switch from meowing to scratching, just remove the meowing instance and create a new instance of cat-scratch in its place, with its position and orientation.

I’m not sure of how this would compare to keeping two cats and two dogs with both animations but which use only one each, and instancing from those, which is the other idea that comes to mind.

It is what I do, more or less, except UniqueActorGenerator will create as many actors for each animations as I ask it to create (or script asks to create). I will have let’s say, “cat-meow startframe = 0”, “cat-meow startframe = 10”, “cat-scratch startframe = 0”, “cat-scratch startframe = 10”, “dog-bark startframe = 0”, and “dog-bark startframe = 10”. And later I will instance one of these unique actors to all NPCs that are doing the same action currently.
I will later post the code, so that it will be easy to see.

Aah, fair enough then - my mistake. :slight_smile: