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

[SOLVED] Activating Particles with a Button!

  • Hey Maxime Cabrol,

    There are scripts you could use ill link one down below one of a video of how to use and create a button and the script is so it enables the button https://www.youtube.com/watch?v=3WHmuo8GY0U 

    Comment actions Permalink
  • // FaceTriggerAnim.js

    // Version: 0.0.2

    // Event: Lens Initialized

    // Description: Plays an animation layer, sound, sprite, on trigger

     

    // @input string AnimationTrigger = MouthOpenedEvent { "widget": "combobox", "values": [ { "label": "Brows Lowered", "value": "BrowsLoweredEvent" }, { "label": "Brows Raised", "value": "BrowsRaisedEvent" }, { "label": "Brows Returned To Normal", "value": "BrowsReturnedToNormalEvent" }, { "label": "Face Found", "value": "FaceFoundEvent" }, { "label": "Face Lost", "value": "FaceLostEvent" }, { "label": "Kiss Finished", "value": "KissFinishedEvent" }, { "label": "Kiss Started", "value": "KissStartedEvent" }, { "label": "Mouth Closed", "value": "MouthClosedEvent" }, { "label": "Mouth Opened", "value": "MouthOpenedEvent" }, { "label": "Smile Finished", "value": "SmileFinishedEvent" }, { "label": "Smile Started", "value": "SmileStartedEvent" }, { "label": "Touch Start", "value": "TouchStartEvent" }, { "label": "Touch End", "value": "TouchEndEvent" }, { "label": "Tap", "value": "TapEvent" } ] }

    // @input int faceIndex = 0

     

    // @ui {"widget":"separator"}

     

    // @ui {"widget": "group_start", "label": "3D Anim Control"}

    // @input Component.AnimationMixer AnimationMixer

    // @input string LayerName

    // @input int animationPlayCount = 1 {"label": "Play Count", "min":-1, "max":99999, "step":1} // How many times to play the animation, -1 for infinite

    // @ui {"widget": "group_end"}

     

    // @ui {"widget":"group_start", "label":"2D Anim Control"}

    // @input Component.Image[] play2dSprites {"label": "Play Animations"}

    // @input int texturePlayCount = 1 {"label": "Play Count", "min":-1, "max":99999, "step":1}

    // @input float texturePlayOffset = 0 {"label": "Play Offset", "min":0.0, "max":99999.0, "step":1}

    // @ui {"widget":"group_end"}

     

    // @ui {"widget":"group_start", "label":"Sound Control"}

    // @input Asset.AudioTrackAsset[] playAudios {"label": "Play Sounds"}

    // @input int audioPlayCount = 1 {"label": "Play Count", "min":-1, "max":99999, "step":1}

    // @ui {"widget":"group_end"}

     

    // @ui {"widget":"separator"}

     

    // @input float TriggerDisableTime = 0

     

    var triggerStartTime = getTime() - script.TriggerDisableTime;

     

    // What happens when event is triggered

    function onTriggered()

    {

    print("FaceTriggerAnim: " + script.AnimationTrigger + " triggered");

     

    // Called when animation ends

    function animationCallback()

    {

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

    }

     

    // Play animation layer with sound (if available)

    if (script.AnimationMixer && script.LayerName)

    {

    script.AnimationMixer.startWithCallback(script.LayerName, 0.0, script.animationPlayCount, animationCallback);

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

    }

     

    for (var i = 0; i < script.play2dSprites.length; i++)

    {

    if (script.play2dSprites[i]

    && script.play2dSprites[i].mainPass.baseTex

    && script.play2dSprites[i].mainPass.baseTex.control

    && script.play2dSprites[i].mainPass.baseTex.control.play)

    {

    script.play2dSprites[i].getSceneObject().enabled = true;

    script.play2dSprites[i].mainPass.baseTex.control.play(script.texturePlayCount, script.texturePlayOffset);

    }

    }

     

    for (var i = 0; i < script.playAudios.length; i++)

    {

    if (script.playAudios[i])

    {

    var audioComponent = getAudioComponentForTrack(script.playAudios[i]);

    audioComponent.play(script.audioPlayCount);

    }

    }

     

    }

     

    // Trigger an action if not in cooldown period

    function triggerCallback()

    {

    if (getTime() >= triggerStartTime + script.TriggerDisableTime) {

    triggerStartTime = getTime();

    onTriggered();

    }

    }

     

    // Setup the audio component if audio track defined

    function getAudioComponentForTrack ( audioTrackAsset )

    {

    var trackName = audioTrackAsset.name;

     

    if (!global.ftAudioComponents)

    {

    global.ftAudioComponents = {};

    }

     

    if (!global.ftAudioComponents[trackName])

    {

    var audioComponent = script.getSceneObject().createComponent("Component.AudioComponent");

    audioComponent.audioTrack = audioTrackAsset;

     

    global.ftAudioComponents[trackName] = audioComponent;

    }

     

    return global.ftAudioComponents[trackName];

    }

     

    // Allow fullscreen tapping if trigger is touch based

    if (script.AnimationTrigger == "TouchStartEvent"

    || script.AnimationTrigger == "TouchStartEvent"

    || script.AnimationTrigger == "TapEvent")

    {

    global.touchSystem.touchBlocking = true;

    global.touchSystem.enableTouchBlockingException("TouchTypeDoubleTap", true);

    global.touchSystem.enableTouchBlockingException("TouchTypeSwipe", true);

    }

     

    var event = script.createEvent(script.AnimationTrigger);

    event.faceIndex = script.faceIndex;

    event.bind(triggerCallback);

    Comment actions Permalink
  • Hey itzjustsamuel,

    Thanks a lot for your answer !

    I will test this right away! t

    hanks again

    Comment actions Permalink
  • By reading the script well, I did not understand very well how to use it.

    Comment actions Permalink
  • so basically the script allows you to trigger anything based on what you choose so you could choose tap on the screen or face gestures to activate it you just have to connect this script to the button and it should work fine :P

    Comment actions Permalink
  • Hello everybody,

    I finally succeeded!

    I finally did not use the script that itzjustsamuel sent me BUT I am a beginner in programming his script helped me better to understand how it worked.

    Thank you !

    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!