Camera Switching
Hi,
I am new to the lens studio, and i am trying to find my way to create my first lens.
I've created a lens with a 3d object and a billboard to add a static text over the object. I want to know how to switch the camera to the front view and see a different text on the other camera and a different 3d object.
any help is highly appreciated
Thanks in Advance
Hi Anas!
Glad you're making your first Lens!
Take a look at BehaviorScript which allows you to do some certain action based on some events:
https://lensstudio.snapchat.com/guides/scripting/behavior-script/
So let's say you have some scene like the following:
Then we can add a new object to control which object is visible depending on the camera. In the Object panel press Add New > Object. Then, in the Inspector panel, press Add Component > Script. Finally press the Add Script button and select the BehaviorScript you've imported from the page above.
Now you should see some options. Select the Trigger drop down and choose "Front camera" Then select the Response Type "Set Enabled". Click the "Target" field and select the object that you want to show up in the Front Camera.
Then we can similarly add another BehaviorScript to this controller object to disable the objects that should only appear in the rear camera.
You can do the same for the Trigger "Back Camera". To enable objects that you want to be visible in the rear camera, and disable objects that you want to not be visible in the rear camera.
Your final scene set up should looks something like this:
And that's it! Let me know if you need any clarification :)
Cheers,
Jon
Dear Jonathan,
I really appreciate your help it really adds a lot to my knowledge in the Lens studio journey :)
I tried it but my set up is different i guess to i didn't know how to handle it in my situation.
what i am planning to do is to have a tracking object like a helmet to set on my face ( which i learned how to do )
now if i opened my mouth lets say or winked i need the camera to switch automatically and show me a 3d object in the world camera ( which i got to know how to make ) with a static txt on it.
i tried the way you explained to me .. but got lots of troubles with the cameras
i guess there are lots of thing still to learn, So i really appreciate if you can help me again.
Appreciate your help and best regards
Hi Anas!
Ah I see. Thanks for sharing your scene, it's very helpful.
It is not possible to have the Lens switch which camera is active. However, you can show a hint to tell the user to switch camera. Take a look at this guide: https://lensstudio.snapchat.com/guides/scripting/scripting-hints/
Additionally, I've modified the WorldObjectController script to allow you to add a list of objects to enable only on the front side:
To use it, in the Resources panel, open the Scripts folder and select WorldObjectController. Then in the Inspector panel, replace the script and press "Apply Changes."
Now, in the Objects panel, when you select FaceImagePickerController, in the Inspector panel you should see a new field called "Front Object Only". You can press the "Add Value" button to add objects you want to only show up in the front camera.
For example, here I added the "2D Sprite 1" object so that the sprite will only show up when the front camera is active.
Can't wait to see what you come up with!
Cheers,
Jon
Awesome, Thanks a lot dear Joe for your help and efforts .. I started getting through ..
I started understanding how it works. Really appreciate your help ..
Thaaaaaanks
Best regards