individual sprite sheet animation for multiple object copies

I have tried two ways of spritesheet animation and both kind of have a big downside, the UVs are always the same for all copies of an object which means the animation is always at the same frame for each.

I made a simple explosion sprite sheet and put it on a plane object with the game properties in the UV/image editor. Everything works fine for that one object.
But when i use scene.addObject to make more copies of the plane, the animation for each of them is at exactly the same. They always display the same frame.

For the second try, i made a script that moves the UV with transformUV essentially doing the same thing, but again all UV data seems to be shared between the planes, they all show the same part of the texture.

How can i make a spritesheet animation that plays independantly for each copy of the plane?

if you are adding the objects from an hidden layer, they will all share the same UV-layout as the main object (in the hidden layer) bout of those methods that you are using is moving the uv that all of the objects are charing, thats why it won’t work 4 you. there are many different work-a rounds to this problem.

If you have an maximum (say 10 explosions) at the same time, you can make 10 hidden copies and an script that is adding them in order, and when maximum is reached, it deletes the first and add it again… this works well whit an UV-scroll script.

You can also use the video-texture module that exist in blender in order to play an animation, this method don’t work whit packed images (as far as I know)

and an third way is to make one separat object/mesh whit every frame, and then add/delete or replace them in order, this method works for endlesly of objects, but is hard to use when you got many frames.

there are also many other ways to do this, but I hope that this at least helped you to get in the right direction :slight_smile:

sry 4 all typos, in my defense: it’s late and my lamp just broke^^

I’m not sure if esoneson is talking about replacing the mesh (when adding the object) with Libnew(), but that might be a good solution.

Attachments

LibNew_01.blend (86.3 KB)

yeah i went with replacemesh(). It works, but needs more time to set up the meshes

You can use the replaceMesh() method (which is what the SpriteMesh() function in my Sprites module does), or you can go with the method you’ve chosen initially, and use LibNew to make a new mesh for each copy that gets spawned.