Playing animation to completion
Hi,
I have a face trigger activated script to play an animation. I don't want a face trigger to restart the animation if it's already being played, but I cant seem to get it to work. Here's what i have so far:
//@input Component.AnimationMixer animationMixer
//@input string animationLayerName = "BaseLayer"
//@input float animationWeight = 1.0 {"widget":"slider", "min": 0, "max": 1, "step": 0.01}
//@input float animationStartOffset = 0.0
//@input int numberOfLoops = -1
// @input Component.MeshVisual screen
var layer = script.animationMixer.getlayer(script.animationLayerName);
if (!layer.isplaying()){
// play 3d anim
script.animationMixer.setWeight(script.animationLayerName, script.animationWeight);
script.animationMixer.start(script.animationLayerName, script.animationStartOffset, script.numberOfLoops);
// play screen movie anim
script.screen.getMaterial(0).mainPass.cullMode = 1
script.screen.getMaterial(0).mainPass.emissiveTex.control.play(1, 0);
}
Hey Sava,
You're super close! Don't forget to check letter casing:
in line 8 it should be "getLayer"
and in line 10 it should be "isPlaying"
Don't forget to share what you make!
Cheers,
Jon
Thanks Joanathan, I cant believe I missed that 🤦♂️🤦♂️🤦♂️ Here's the link to the lens:
https://www.snapchat.com/unlock/?type=SNAPCODE&uuid=fa9191a657184231b2fe752ea99603a4&metadata=01
Wow that's so cool! Thanks for sharing 👊