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

Confetti Cannon Trigger (Help)

  • Hi  Otfcodyp,

    Sounds awesome! Let's do it. 

    First lets make our particle use external time--that way we can set when we want the particle to play. In your Resources panel, select your particle's material, and in the Inspector panel tick "External Time"

     

    Then let's create a new script to control this External Time parameter.

    In the Objects panel, select the object which contains your particle's Mesh Visual. Then, in it's Inspector panel press "Add New" and select script. Press "Add Script". In the dialog box, press "Add New" > Script. 



    Then locate this new script in your Resources panel and edit it. 

    In this script we first want to access the Mesh Visual so we can access the particle. 

    var meshVis = script.getSceneObject().getFirstComponent("Component.MeshVisual");

    Then we'll set up a variable to track the start time of our particle. We'll also create an event which will set this variable when the user opens their mouth. 

    var startTime;

    function onMouthOpened()
    {
    startTime = getTime();
    }
    var updateEvent = script.createEvent("MouthOpenedEvent");
    updateEvent.bind(onMouthOpened);

    Finally, on every frame update after the user has opened their mouth (startTime is set), we can calculate how many seconds have elapsed since then and set that as our particle's external time!

    function update()
    {
    if (startTime) {
    var particleTime = getTime() - startTime;
    meshVis.mainPass.externalTimeInput = particleTime;
    }
    }
    var updateEvent = script.createEvent("UpdateEvent");
    updateEvent.bind(update);

    So our final script looks something like: 

    var meshVis = script.getSceneObject().getFirstComponent("Component.MeshVisual");
    var startTime;

    function update()
    {
    if (startTime) {
    var particleTime = getTime() - startTime;
    meshVis.mainPass.externalTimeInput = particleTime;
    }
    }
    var updateEvent = script.createEvent("UpdateEvent");
    updateEvent.bind(update);

    function onMouthOpened()
    {
    startTime = getTime();
    }
    var updateEvent = script.createEvent("MouthOpenedEvent");
    updateEvent.bind(onMouthOpened);

     

    Let me know if I can clarify anything. Can't wait to see what you make!

    Cheers,

    Jon

     

     

    Comment actions Permalink
  • Hey Jon,

     
    Thanks so much for responding to my post. I've implemented the script you gave me but now the particles have stopped appearing entirely, did I miss a step when implementing the script? Would it be helpful if I sent you the file to view?
    Comment actions Permalink
  • Hi Otfcodyp,

     

    The particles stopping is a good first step--since it will allow us to start the particles!

    Do you see any error in the Logger panel? 

    Just to make sure: Is the script attached to the same object as where the particles' mesh visual is attached (see screenshot above)? And please make sure the script is set to initialized. Finally don't forget to open your mouth, since that is what we set the script to trigger on.

    If it's still not working, yes the file will definitely help :)

     

    Thanks!

    Jon

    Comment actions Permalink
  •  Hi Jon,

    I believe I have double checked everything you recommended but it still is not activating. Here is a dropbox link to the file:

    https://www.dropbox.com/s/xj5x9lkkxz8xt90/Confetti%20Filter%20Newest%20Test%20Zip.zip?dl=0

    Thanks!

    Comment actions Permalink
  • Hi Otfcodyp,

    Thanks for sending the file! This Lens is looking cool.

    Should I be looking at the Splat particle? I can't see the particle system even when I turned off External Time?

    But I did notice a few things:

    • Please make sure that the objects are enabled to begin with (otherwise the script can't run). We can control the particle's visibility using External Time.
    • Additionally, it looks like the Splat Particle Script is set to Mouth Opened--please set it to Initialized. This should be set on Initialized because the script creates the Mouth Opened event when it runs. 

    Thanks!

    Comment actions Permalink
  • Hi Jon,

    I found the problem I was having and the script is working great now, thank you for your help! The final problem I am having is in terms of submitting my lens for use; the current size is 6.75 mb and I am trying to reduce it down to the 4 mb limit. I have already tried the optimization feature that removes my unused objects/resources and it is still too large. Below is a link to the new file, please let me know if you have any suggestions/tips for decreasing the size.

    Thanks!

    https://www.dropbox.com/s/pqoodmkqlozawya/Compression%20Test.zip?dl=0

    Comment actions Permalink
  • Hi Otfcodyp,

    Glad to hear you got it to work!

    I took at the file you uploaded, it looks like some of the png can be compressed to reduce Lens size. For example, "floating on top Sticker_0" can be reduced several mb. You can use something like TinyPNG.com to help you with this. Please take a look at the following pages for additional information:

    https://lensstudio.snapchat.com/guides/2d/2d-optimization/

    https://lensstudio.snapchat.com/guides/submission/performance-and-optimization/

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

    Cheers,
    Jon

    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!