Random Animations and Sounds

This is maybe more of a feature request but anyway, I have three questions:

  1. Does Panda have a built-in ability to play random animations for the same animation name?
    For example:
    nodePath.loadAnims({‘Animation 1’:[‘Animation 1 Path 1’,‘Animation 1 Path 2’]}

  2. Does Panda have a built-in ability to load a few different sounds into one sound object and then automatically play a random sound?
    For example:
    audio3d.loadSfx(“sound*.wav”)
    This would load sound1.wav, sound2.wav and sound3.wav and play one of these sounds randomly.

  3. Can sounds be played on certain specified frames of certain animations?
    For example, if I have a walk animation, I want a footstep sound to be played automatically on frame 10 and 20.

I have found a way to do all this with my own programming but its too slow. After having 3 NPCs that use these abilities the framerate drops from 85 to between 65 and 75. Could these abilities be added to Panda?

Panda doesn’t have this built-in, but you can do it yourself easily with:

actor.play(random.choice(['anim1', 'anim2']))

which is just as fast as it would be if the code were built into Panda. If this results in slowdowns for you, it must be because of something else, not because of the call to random.

You can start a sound in the middle easily by wrapping it in a SoundInterval. Or, you can call sound.setTime(t); sound.play() to start it at time t, in seconds.

David

Footsteps can be done with intervals, that is if it is someone who is walking properly. What if the character is a zombie who has irregular footsteps and also sometimes slides his feet, which would mean that on some footstep frames you would have a normal footstep sound and on certain others it would be a sliding sound.

Do you think I could try to use intervals for this aswell? What if I want to use the same programming for a different zombie who is walking in a completely different way?

David, have you seen how Valve’s animation system works? I’m trying to get someting similar to work. Acting is made so much easier if you can have a character say stuff on certain frames…

You could do a zombie walk with intervals too. One easy thing would be to call out to a func from your intervals, and that func would choose randomly which of the three or four different zombie footsteps to play.

I agree it would be easier to get explicit callbacks at particular frames of animation. I’ve put it on my list. If anyone else wanted to code up that particular feature before I got to it, I wouldn’t be sad. :slight_smile:

David