Suggestions for Muzzle Flash

I have a gun that has a very high fire rate. I am using an actor with a short animation for a muzzle flash, and attaching it to a dummy node at the end of the barrel.

This works great… for one muzzle flash.
When I start rapidly firing, the flash seems to start over from the beginning every time, and sometimes skips the render altogether. I am sure this is due to creating and deleting new nodes.

I toyed with instancing the actor, but I can only seem to get it to animate the one actor, and all others share the same frame, not ideal for this situation either.

What I need is to store off the original actor,a nd copy it every time I create a muzzle flash, so I get the overlap I am looking for.

I see there is a method def copyActor(self, other, overwrite=False), but it is undocumented, and I cant seem to get the syntax right. Then again I may be barking up the wrong tree too.

Any suggestions?

copyActor() is not intended to be called directly, but you can use newActor = Actor(oldActor) as a copy constructor.

Still, I don’t think the results of using the copy constructor will be very different from recreating a new Actor from scratch each time. In either case, the copy will start from the beginning each time you play, as it should. I’m not sure what you want to happen–do you want the copy to start from the same frame that the original is currently playing, instead of from the beginning? You could do that with an explicit frame number on the play() call, but then your two animations will be precisely in sync, exactly the problem you have when you use instancing.


Thanks David,
I was able to get a respectable firing rate from just creating the new actors, which makes me believe the model is being kept in ram, rather than reading from the disk. I decided the best route was to keep a pointer to some pre-loaded models hanging around, and just make new Actors… thus making sure the model stayed in ram.

I am having an issue with ODE projectiles still, this particular projectile (from a 50 cal) has an effective range of over a mile. To get it to travel that far I have to crank the velocity to extremely high levels, which works great at that distance, but they travel entirely too fast for nearby targets, and pass right through them. I am considering making a variable velocity to rectify this, but alas this demonstration is being designed to be real-world accurate, and that would be a pretty bad hack on my part.

If you have any suggestions for that I’d be grateful
Thanks again for all your help

Iirc, Panda does have some builtin support for high-speed collision testing. If you need to write your own, the basic premise will be to see whether the paraboloid traced by your shot intersects a target (if you’re too keen on physical accuracy to use something other than f=ma for your motion, I’m assuming you’re also either in a vacuum or factoring in air resistance, and needing this for scientific visualization or something. Otherwise, the player is never going to see or care how the shot goes away after the known max range). A hack would be to just check the line between the shot’s positions across any 2 frames. I’d imagine this is more what Panda’s high-speed collisions will give you.