different design for each camera

  • Hi Bayader,

    I can explain how you would include the script n your project.

    Create the Script Asset

    1. In Resources, select Add New > Script
    2. Select the new Script and past the following code in the Script Editor found in the Inspector Panel:
       
      // Use in "Initialized' event

      //@input SceneObject target

      //@input bool activeOnFront

      //@input bool activeOnBack

      script.createEvent("CameraBackEvent").bind(function (eventData)

      {

          script.target.enabled = script.activeOnBack;

      });

      script.createEvent("CameraFrontEvent").bind(function (eventData)

      {

          script.target.enabled = script.activeOnFront;

      });
       
    3. Select 'Apply Changes' 

    Apply the Script to your Face Sprite

    1. Create a new SceneObject in the Objects Panel and select it.
    2. In the Inspector, select Add Component > Script
    3. On the new Script component, select "Add Script"
    4. In the selection popup, select the Script asset you created in the first section. Select 'OK'
    5. Make sure the dropdown next to the script name is set to 'Initialized'.
    6. In the Inspector, click the field labeled "Target".
    7. In the selection popup, select your Face Sprite object.
    8. In the Inspector, check the box "Active On Front"

    Apply the Script to your Billboard

    1. Create a new SceneObject in the Objects Panel and select it.
    2. In the Inspector, select Add Component > Script
    3. On the new Script component, select "Add Script"
    4. In the selection popup, select the Script asset you created in the first section. Select 'OK'
    5. Make sure the dropdown next to the script name is set to 'Initialized'.
    6. In the Inspector, click the field labeled "Target".
    7. In the selection popup, select your Billboard object.
    8. In the Inspector, check the box "Active On Back"

    Now, when you test the lens you should see the Face Sprite only on the front (selfie) camera, and you should see the Billboard only on the back (world) camera.

    Let me know if you have trouble with any of the steps I described above, and I'll be happy to help!

     

    Best,

    Peter

    Comment actions Permalink
  • Hi Bayader,

    Can you explain a bit more what you had in mind?

    Cheers,
    Kaitlyn

    Comment actions Permalink
  • like on the front camera (only) i would like to have a face sprite

    and on the rear camera (only) i would like to add another billboard 

    Comment actions Permalink
  • Hi Bayader,

    Here's a script that should make it easy to show content specifically on the front vs rear camera:
     
    // Use in "Initialized' event
    //@input SceneObject target
    //@input bool activeOnFront
    //@input bool activeOnBack
    script.createEvent("CameraBackEvent").bind(function (eventData)
    {
        script.target.enabled = script.activeOnBack;
    });
    script.createEvent("CameraFrontEvent").bind(function (eventData)
    {
        script.target.enabled = script.activeOnFront;
    });
     
    Add this script to objects you want to enable / disable based on camera
    Make sure they are added to the "Initialized" event
    Turn "activeOnFront" on for objects active on front camera
    Turn "activeOnBack" on for objects active on rear camera
     
    Let me know if you need clarification on how to add this to the Lens and I'd be more than happy to further assist.
     
    Cheers,
    Kaitlyn
    Comment actions Permalink
  • Thanks Kaitlyn, please forgive me but would you explain it a little for me? thanks

    Comment actions Permalink
  • 22:36:50 TypeError: cannot write property 'enabled' of undefined
    at [anon] (Script:22) preventsyield

    what does this means?
    Comment actions Permalink
  • Hi Bayader,

    This error means that the Script Component's properties were not set up before running the script. From the steps I shared earlier, be sure to complete steps 6 - 8. This tells the script which object we're enabling/disabling when you swap cameras.

    Let me know if that works for you.

    Best,

    Peter

    P.S. Just for your information, The part that reads 

    (Script:22)

    tells us that the error is related to code on line 22 of the script : )

    Comment actions Permalink
  • ok Thanks Peter, i messed step 6 :)

    i pushed the lens to my device and it works but when i flip more than once the things i "scripted" disappeared :(

    i'm still learning the stuff, sorry for all the questions

    another thing, how do i make a 3D particles? like the Bokeh templates? i tried to change the texture but it got cropped! and then i tried to make my setting just like the templates but it didn't work either :( 

     

     

    Comment actions Permalink
  • They're probably disappearing because the script to enable/disable the object is on the object itself. Since the object is being disabled, its script will not run. I recommend creating a new Scene Object and attaching the Script Component to it, as mentioned in step 1. Be sure to the Script Components you already placed.

    As for particles, I recommend following the Particles Template Guide: https://lensstudio.snapchat.com/templates/world/particles/

    The cropping of the textures might happen if the particle has been set to flipbook/animated when your texture is not meant to be animated.

    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!