The forum on this site is closed for new comments and posts. Continue the conversation in our Snap AR Discord server.

Creating a Script to play different animations based on what user selects

  • Hey Chris,

    Jonathan helped out another community question with a similar question a couple months ago here. Does this post help you achieve the effect you were hoping for?

    Cheers,
    Kaitlyn

    Comment actions Permalink
  • Yes this helps. I've actually been able to figure out how to do it using the Soundboard Template. Would you also be able to answer a question I have, I am looking to track the person's face to a video animation, is this doable in Lens Studio?

    Comment actions Permalink
  • Sure, happy to help here. Can you explain a bit more the effect you're hoping to achieve though?

    Comment actions Permalink
  • Hi Kaitlyn,

     

    I am looking to create a Lens where the user can select between 6 different buttons, giving them a specific animation of someone dancing and the face is cut out so the user can have their face in there. Right now when I try and add the face inset it is being applied below the billboard (video). Hope this explains it well enough. 

     

    Thanks,

    Chris

     

    Comment actions Permalink
  • Another issue, probably really easy on our end just I have no idea how to make my billboard object disappear from the start. Basically what I have now are two buttons that trigger different animations which is what I want. The problem is, that when I preview on my device, the animation is already playing from the start without pressing the buttons. How do I fade in or just pop in the animation so its not just idling on the screen at the start?

    Would be a huge help. Much appreciated!!!

    Comment actions Permalink
  • Hey Chris,

    To hide a object on the start you can simply disable the object. Like this:

    For the animation you can use the Animation Mixer API page to pause the animation on initialize of the lens:

    https://lensstudio.snapchat.com/api/classes/AnimationMixer/

     

    // PlayAnimation.js
    // Version: 0.0.3
    // Event: Lens Turned On
    // Description: Plays a single animation on an animated mesh. If an AnimationMixer is not set, the script will attempt to find one on the SceneObject.
    //    @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
    if(!script.animationMixer)
    {
        script.animationMixer = script.getSceneObject().getFirstComponent("Component.AnimationMixer");
    }
    if(script.animationMixer)
    {
        script.animationMixer.setWeight(script.animationLayerName, script.animationWeight);
        script.animationMixer.start(script.animationLayerName, script.animationStartOffset, script.numberOfLoops);
    }


    the script above will play animation automatically and you can use the script and replace the start() with pause().

    Please refer to API page to learn more about AnimationMixer component.

     

    Best,

    Amir.

    Comment actions Permalink
  • Hey Chris, if you're looking to create some sort of button for the certain animation,

    I have made you a project with 6 buttons.

    mega.nz(download)

    Hopefully this should make it much easier for you to make what your looking for :)

    Wish you the best,

    Matthew

    Comment actions Permalink

We're here to help! We just need a little bit of information...

What system are you using?

Have you downloaded the latest version of Lens Studio?

Please download the latest version of Lens Studio. If you still run into this issue, please come back and report it!

Is this issue causing Lens Studio to crash?

What system do you run Lens Studio on?

Version

Graphics

Follow the next steps to help us solve your issue:

  • Copy and paste this text into your TerminalCommand Window
    open ~/Library/Preferences/Snap/Lens\ Studio/ %LOCALAPPDATA%\Snap\Lens Studio Copy Text
  • Press ReturnEnter to run the command. The Lens Studio folder will automatically open
  • Prepare to upload your files: zip the "Log" Folder by right-clicking and choosing "compress."
    Locate the Log.txt file right above it.

    Attach a screenshot of the issue:

Name:

Email:

What is this most relevant to?

Please enter a brief description of your issue:

Thanks for submitting this issue.

Unfortunately, it's likely due to the operating system or hardware you're using – since they don't meet the system requirements for Lens Studio.

Still, we hear you loud and clear, and are logging the issue in case there's ever a workaround we can provide!

Minimum Requirements

Operating System: Windows 10 (64 bit); MacOS 10.11+

Hardware: Minimum of Intel Core i3 2.5Ghz or AMD Phenom II 2.6Ghz with 4 GB RAM; Intel HD Graphics 4000 / Nvidia GeForce 710 / AMD Radeon HD 6450 or better; screen resolution of 1280x768 or higher

We'll try to resolve this issue as soon as possible. Thanks for letting us know about it!

Keep an eye out for a followup email from us. We may have a couple more questions for you, or we might already have a solution to offer.

Happy creating!