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

How do I make my 2d animation disappear after it has ended?

  • Hi there, probably the easiest way to make an anim disappear is to simply disable the SpriteVisual. Here's a script that takes in a Sprite Visual via the Inspector and plays the animation once. Then, it registers a callback for when the animation finishes. Upon finish, it disables the sprite visual. Hope that helps!

    // -----JS CODE-----
    //@input Component.SpriteVisual myAnimation

    script.myAnimation.enabled = true;
    script.myAnimation.getMaterial(0).getPass(0).baseTex.control.play(1, 0.0);
    script.myAnimation.getMaterial(0).getPass(0).baseTex.control.setOnFinish( onAnimationFinished );

    function onAnimationFinished()
    {
    script.myAnimation.enabled = false;
    }
    Comment actions Permalink
  • It says: cannot write property 'enabled' of undefined at [anon] (script:16) preventsyield

    Comment actions Permalink
  • Make sure you've linked the animation to the script in the Inspector. 

    • First, add the script to an empty game object
    • Select the object with the script in the Objects panel
    • In the Inspector panel, find the script and click the "myAnimation" field
    • Find the 2D animation in your scene and select it
    • Press refresh in the Preview panel and the error should go away

    Cheers,

    Travis

    Comment actions Permalink
  • Thank you for your answer :) It worked but when I press it again you only hear the sound from the animation, how can I make it that when I press the screen again it replays the animation with the sound?

    Comment actions Permalink
  • I found something and everything is finished but now my file is to big and if I remove frames the file becomes bigger for some reason.

    Comment actions Permalink
  • When importing a 2D animation, one or more sprite sheets are created. One way to reduce the size of the animation is to set the File Count parameter to a lower number on import (which represents the number of resulting animations). 

    Besides file count, likely your resulting sprite sheets created in the animation tool aren't compressed. There are two ways to fix this. 

    1) Reimport your animations and lower the quality which will use compression (bottom right hand corner of the animation import tool). Try to use a low number here for a smaller file size

    2) You can also compress your already exported animations. To do this, go to your projects folder on your computer. There you will see a Public folder. In the Public folder, there should be another folder (named the animation name) which has your exported animation. Take all the images in there and run them through https://tinypng.com/ which will compress them quite a bit. Replace the images with the compressed ones. Your lens should now fit within the 4 mb limit

    More info can be found here:

    https://lensstudio.zendesk.com/hc/en-us/community/posts/115020415343-Optimizing-2D-Textures-Best-Practices

    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!