The forum on this site is closed for new comments and posts. Continue the conversation in the new forum, and learn more here.

Having trouble starting particle systems from script

  • Hi Frank!

    How GlobalTime and ExternalTimeController work with particle system material

    You're right, GlobalTime and ExternalTimeController will help you with this.

    ExternalTimeController connects with the variables exposed by the particle system inspector where it says 

    meshVis.getMaterial(0).mainPass.externalTimeInput = positiveTime-0.01;

    That is: it is looking for a mesh visual in the same SceneObject where the script is added to, accessing its material (the particle system) and modifying it's time (what state the particle system is in). 

    Above that, we can see that positiveTime, is a variable based on global.controlTime, which is set by the GlobalTime.js

     global.animTime = global.controlTime - getTime();
    var positiveTime = -animTime * 0.5;

    In other words, these two scripts control what state the particle system is in by storing when the lens started (global.controlTime), and then calculating how long time has passed, and finally passing it into the particle material. 

    It's important to note, that the particle system has a checkbox to tell it to use externalTime rather than its own time. 


    (Re)starting material

    Currently, in ExternalTimeController, there is a function called resetTime which resets the particle system after a certain time has elapsed. This is how you can restart the particle system. We can repurpose this to reset the particle system on command.

    Let's say we want the particle system to restart when the user taps. 

    What we need to do is to remove the time check if statements  and then bind the reset function to the touch event. 

    global.touchSystem.touchBlocking = true;
    function resetTime(time)
    print("RESET TIME")
    global.controlTime = getTime();
    var ts = script.createEvent("TouchStartEvent");

    Alternatively, we can expose this function to other scripts so that they can call it.

    function resetTime(time)
    print("RESET TIME");
    global.controlTime = getTime();
    script.api.resetTime = resetTime;

    and then in the other script, we can get a reference to this script component / function

    // @input Component.ScriptComponent partcleExternalTimeController


    Check out the API Reference section here:

    That's a great idea on particle system component--I will pass that on to the team :)


    Can't wait to see what you come up with!


    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?



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:



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!