Scripting an animated Opacity Mask
Hi friends!
I'm trying to script the playing of a couple of animated .mp4 Opacity Masks, and am having a doozy of a time.
Using the new Behavior script with the animated mask selected for "Animated Texture" and the Screen Image object in question for the "Visual Object" is returning an error of wrong argument number count.
Using a custom script on the Screen Image object also seems to not be working:
var myAnimation = script.getSceneObject().getFirstComponent("Component.Image");
var loops = 0;
var offset = 0.0;
myAnimation.mainPass.opacityTex.control.play(loops, offset);
This also returns a wrong argument count error on line 4: 1 expected, got 2.
My goal is simply to have the masks not animate until a trigger is satisfied, then play once.
Thanks for all of your help!
Hey Zach,
Can you share your project including your animation so i can take a look for you?
Thanks for the offer! Here it is a bit cleaned up but with the errors still occurring.
http://shot.blackandred.io/b9b25acfcad7
Hey, Thank you for providing the project file.
Here's the project you wanted.
It plays once when you open your mouth.
https://drive.google.com/open?id=1HIVyKdFN3bv4i_prl2sbPCB_ZuOH631y
Let me know if i can help you with anything else.
Whoah, thanks! It was really stumping us. Appreciate the help.
This is kinda like the solution we actually just came to! Now trying to tackle how to get the animation to not be at the endframe when the lens is loaded. May have to just enable it on trigger.
Hi Zach!
You can add a script on Initialized to set the animation position when the Lens is loaded:
Then, when you use that script you should have an input field where you can put your texture and have it start on the first frame.
Can't wait to see the result!
Cheers,
Jon
Perfect, thanks Jon!