Blinking commands
Rich ⚡️ضع إيماني بالله 🌊
Posts: 2
Hey dev fam!
I am trying to create a glasses lens that alternates between 2-3 glasses whenever the Snapchat user blinks.
Any leads on how I can do this
Thanks
Richie
0
Answers
-
You can detect blinks using the Blink Detection feature in the Face Tracking component. Here's how you can use it to alternate between glasses:
- Add a Face Tracking component to your scene and enable Blink Detection.
- Create a script and attach it to the root object in your scene.
- In the script, get a reference to the Face Tracking component and the glasses you want to alternate between. You can do this in the script's start function:
// Get a reference to the Face Tracking component var faceTracking = script.getSceneObject().getFirstComponent("Component.FaceTracking"); // Get a reference to the glasses objects var glasses1 = script.getSceneObject().getObjectByName("Glasses1"); var glasses2 = script.getSceneObject().getObjectByName("Glasses2"); In the script's update function, check the blink strength of the Face Tracking component. If it's above a certain threshold, toggle the visibility of the glasses objects: Copy code // Check the blink strength if (faceTracking.blinkStrength > 0.5) { // Toggle the visibility of the glasses glasses1.enabled = !glasses1.enabled; glasses2.enabled = !glasses2.enabled; }
This will toggle the visibility of the glasses objects whenever the user blinks with strength above 0.5. You can adjust the threshold to suit your needs.
0 -
I do not see a face tracking component in Lens studio. Was it removed or renamed? I'm on version 4.55.1
0