duplicating sprite withe animated texture just loops all
So here is the scene
duplicated objects 4
each object has a child sprite
with BaseTex loading single animation texture
on Tape event it should play that sprite but it's playing all BaseTex on all child object sprites
I am thinking my issue is baseTex is the same animation so calls it on all despite the tap event been for unique sprite
at 5.30 am any help would be appreciated
// Play animation
var control = script.Guts1.getMaterial(0).getPass(0).baseTex.control;
if( control && control.play )
{
control.play(1, 0.0);
}
Ah, this is something that's confusing with the sprite object. When you duplicated the sprite, it duplicated the object but retained the reference to the same material. So, all of your sprites are actually using the same material. So, when you set and play the animation, it's setting the material which is shared by all. Hence, they all play the same animation.
To fix this, try four new sprites. Go to Add New -> Sprite in the Objects panel for each sprite you want to use. These will now each have a unique material instance which will allow them to be set independently.
I've filed a ticket to try and improve this. Thanks Patrick
Tried this no luck, look forward to a fix please
Hey Patrick, four new sprites should work. Can you elaborate a bit on where you're having trouble? If you can, please post the script where you're having this issue and I can try to debug it.
We're having the same problem Patrick is having. Creating new sprites instead of duplicating them did not fix the problem. I believe that as the texture animations are the same even though materials are different, when i call baseTex.control.play, it starts playing the one texture animation i have in my project for all materials that reference it. I believe the only way to fix this is to duplicate texture animations, which is a problem because of file size.
There is of course the big possibility that i'm doing something wrong
Ah sorry, I misunderstood the question! Didn't realize that we were talking about four of the exact same texture. Yes that makes sense. The actually animation playback is on the animated texture asset as you mentioned. Specifically this class which is a part of the Asset.Texture asset type:
https://lensstudio.snapchat.com/api/classes/AnimatedTextureFileProvider/
And you are correct, the only way to have the same texture playback at different rates is to duplicate the texture asset. I'll put a feature request in to better handle this case. In the meantime, unfortunately you'll have to copy your texture.
Quick follow up! Any duplicated asset that is the exact same are handled nicely in the final lens. Basically, all duplicates are removed and only a single copy remains which all of the duplicated resources will reference. Because of this, as long as you don't make changes to the assets independently, you should be able to duplicate textures for offset animation playback without impacting your Lens size.
Hey Travis, thanks for the update,
yes I think I am seeing this if I duplicate within objects and not within resources but the issue still remains you can't press play on one duplicated animation sprite without the rest playing as well.
Yes, I misunderstood the question. Because you are using the same texture, if you want them to have independent playback, you have to duplicate the actual resource. That said, because Lens Studio intelligently removes duplicate resources in the process of packaging the lens, you don't have to worry about increasing your lens size when you duplicate the resources as long as they remain identical.