Start and stop the particles

  • I'm just a beginner with Lens Studio, so this might be not work for your use case but I have typically used the behavior script (Baked in with LS2.0) for starting and stopping objects.  

    Comment actions Permalink
  • Hi Furkan!

    Eric is right, you can use the Behavior Script to help with this. To add Behavior Script:

    Then select the new object, and in its Inspector panel, you can have the end of an animation trigger a function.

    To create a callback to this trigger, create a script and attach it to an object.

    Then in the script do something like

    // -----JS CODE-----
    // @input Asset.Material particleMaterial

    // Listen to the behavior script event
    global.behaviorSystem.addCustomTriggerResponse("play-particle", function() {
    // Emit 100 particles
    script.particleMaterial.mainPass.spawnMaxParticles = 100

    // Stop emitting particles after 2 seconds
    stopParticle.reset(2);
    })

    var stopParticle = script.createEvent("DelayedCallbackEvent");
    stopParticle.bind(function(eventData)
    {
    // Stop emitting particles
    script.particleMaterial.mainPass.spawnMaxParticles = 0
    });

    In the Inspector panel, where you put the script, you can attach your particle's material to the input

    To make sure the particles don't start playing when the Lens start, select the particle material and set its Particle Count Amount to 0

     

    The last thing you need to do is tell your image to not auto-play, since we want it to only play once so we can get the animation end callback. Select the animation in the Resources panel, and then until Always Play in the Inspector panel. 

    To get it to play when the lens turn on, we can use the Behavior Script as well:

     

    And that's it! Your particle should now play after the animation ends, and stop after 2 seconds. Let me know if you need any clarification!

     

    Can't wait to see what you come up with :)

    Cheers,

    Jon

    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!