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

Animations without layers problem

  • The other issue I'm having is getting the animation to loop back to idle after the tapped animation finishes.

    Currently the lens just stops after the tapped animation.

    Comment actions Permalink
  • Hello Tom,

    You can follow Animation without layer guide and use the custom script that is provided to have your animation to loop back idle after the tap animation.

    Just make sure to download the Interactive Tap template file and replace both script with the provided scripts.

     

    For the blending between the two state of the animation you need to setweight for your Animation mixer, the max value for the weight is 1. When you put 1 on the setweight your animation will play normally and if you want to blend with two state you have to lower the weight of your first animation from 1 to zero and for the second animation change your value from 0 to 1. In this way you can blend between your animations.

    we use Lerp to linearly interpolates between two vectors.

    I created a script which will let you too blend between two animation layers

     

    // -----JS CODE-----

    // @input Component.AnimationMixer AnimationMixer

    // @input string IdleAnimLayer

    // @input string IdleAnimLayer2

    // @input float blendDuration

    var blendValue;

    var isBlending = false;

    var timeStartedBlending = 0.0;

    var timeSinceStarted

    var percentageComplete;

    var startBlendValue = new vec2(0,1);

    var endBlendValue = new vec2(1,0);

    script.api.idleAnimLayerName = script.IdleAnimLayer;

    script.api.idleAnimLayerName2 = script.IdleAnimLayer2;

    script.api.animMixer = script.AnimationMixer;

    var event = script.createEvent("UpdateEvent");

    event.bind(onUpdateEvent);

    var tapEvent = script.createEvent("TapEvent");

    tapEvent.bind(onTap);

    var turnOnEvent = script.createEvent("TurnOnEvent");

    turnOnEvent.bind(onLensTurnOnEvent);

    function onLensTurnOnEvent()

    {

    script.AnimationMixer.start(script.IdleAnimLayer, 0, -1);

    script.AnimationMixer.setWeight(script.IdleAnimLayer, 1.0);

    script.AnimationMixer.start(script.IdleAnimLayer2, 0, -1);

    script.AnimationMixer.setWeight(script.IdleAnimLayer2, 0.0);

    }

    function onUpdateEvent(eventData)

    {

    if(isBlending)

    {

    timeSinceStarted=getTime() -timeStartedBlending;

    percentageComplete=timeSinceStarted/script.blendDuration;

    blendValue=vec2.lerp(startBlendValue, endBlendValue, percentageComplete);

    script.AnimationMixer.setWeight(script.IdleAnimLayer, blendValue.y);

    script.AnimationMixer.setWeight(script.IdleAnimLayer2, blendValue.x);

    print(blendValue.x+" "+blendValue.y);

    if(percentageComplete>=1.0)

    {

    isBlending=false;

    }

    }

    }

    function startLerping()

    {

    isBlending=true;

    timeStartedBlending=getTime();

    timeSinceStarted=0;

    percentageComplete=0;

    }

    function onTap(eventData)

    {

    startLerping();

    }

    Best, 

    Amir.

     

    Comment actions Permalink
  • Hi Amir,

    Thank you for your help.

    I'm still having trouble implementing this and I've followed the Animation without layers guide but I'm still not getting the loop back to idle after the tap animation.

     

    I've attached project folder so you can see what my setup looks like. I'm currently using the idle, tap and your blend script above all at once.

    the idle animation is 0.00 - 9.00 and tap animation 9.00-12.00

    https://drive.google.com/file/d/1uaPFkXn-GfP3deaQ6nRZ4HI3X1nAyZsa/view?usp=sharing 

    Comment actions Permalink
  • Hi Tom,

    To loop your animation from tap to idle, please open the "TapAnim" script file in your project and change the line 80 from:

    if(self.AnimationMixer.getLayerTime(script.api.animLayerName) > script.actionAnimEnd)

    to this one:

    if(self.AnimationMixer.getLayerTime(script.api.animLayerName) >= script.actionAnimEnd)
     
    It should fix the problem for you.
     
    Best,
    Amir
     
     
     

     

    Comment actions Permalink
  • Great thank you Amir that worked.

    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!