How to loop 3 triggers

  • Hi Liane,

    Behavior script doesn't support this on its own right now. But you can use a simple script to cycle through a few Behavior scripts.

    // @input Component.ScriptComponent triggerBehavior
    // @input bool autoTriggerFirst = true
    // @input Component.ScriptComponent[] responseBehaviors

    var curIndex = -1;

    function triggerCurrent() {
    script.responseBehaviors[curIndex].api.trigger();
    }

    function next() {
    curIndex = (curIndex+1) % script.responseBehaviors.length;
    triggerCurrent();
    }

    script.triggerBehavior.api.addTriggerResponse(next);

    if (script.autoTriggerFirst) {
    next();
    }

    Just add this to its own object.

    For "Trigger Behavior", hook up a Behavior that has the "Brows Raised" trigger type and "None" response type. 

    For "Response Behaviors", add all the Behaviors that you want to trigger to this list. Make sure that "Trigger Type" is set to "None" for all of them.

    Hope this makes sense. Let me know if you need any more help!

    Jacob

    Comment actions Permalink
  • Hi Jacob, 

    Thanks for the support.

    I managed to create a lens that circled through following Behaviour Scrips:

    Set 1 (Image Mouth) Enabled

    Set 1 (Image Mouth) Disabled

    Set 2 (Image Lips) Enabled

    Set 2 (Image Lips) Disabled

    Set 3 (Image Clouds) Enabled

    Set 3 (Image Clouds) Disabled

    All of them are attached to the users Lips as a test

     

    What I would like to do is to do the following

    Set 1 (Image Mouth) Enabled

    Set 2 (Image Lips) Enabled, (Image Mouth) Disabled

    Set 3 (Image Clouds) Enabled, (Image Lips) Disabled

    >

    Set 1 (Image Mouth) Enabled, (Image Clouds) Disabled

     

    I tried to put Enable and Disable in one Behaviour Script - But it won´t work.

    how do I approach the second use case?

     

    Many Thanks for your Support!

    Comment actions Permalink
  • I also tried it out on Background Segmentation with Response Type Animate Image and it worked really well :D Thank you for the script :D

     

    Comment actions Permalink
  • Hey Liane,

    I'm glad the script worked for you!

    For your other question, here's a variation on that script which will treat all the Behavior scripts on an object as a set, and trigger them all at once. So for each set, you should group all the Behaviors you want onto the same object.

    // @input Component.ScriptComponent triggerBehavior
    // @input bool autoTriggerFirst = true
    // @input SceneObject[] responseSets

    var curIndex = -1;

    var scriptSets = [];
    for (var i=0; i<script.responseSets.length; i++) {
    var obj = script.responseSets[i];
    var componentCount = obj.getComponentCount("Component.ScriptComponent");
    var set = [];
    for (var j=0; j<componentCount; j++) {
    var scriptComponent = obj.getComponentByIndex("Component.ScriptComponent", j);
    if (scriptComponent.api.trigger) {
    set.push(scriptComponent);
    }
    }
    scriptSets.push(set);
    }

    function triggerCurrent() {
    var set = scriptSets[curIndex];
    for (var i=0; i<set.length; i++) {
    set[i].api.trigger();
    }
    }

    function next() {
    curIndex = (curIndex+1) % scriptSets.length;
    triggerCurrent();
    }

    script.triggerBehavior.api.addTriggerResponse(next);

    if (script.autoTriggerFirst) {
    next();
    }

    Let me know if you need any more help!

    Comment actions Permalink
Have a comment?

Please sign in to leave a comment.

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!