Getting a Gif to appear when you open your mouth?
Hi there,
I'm making a filter where I want it to look like there's a cloud coming out of your mouth when you open it.
I already have a gif for it, but I can't seem to get it to trigger when I open my mouth.
Any help?
BTW I do not know how to write scripts so any help with scripts and stuff would be greatly appreciated.
Thanks!
Hi Rydumais!
You can do this by using the BehaviorScript!
Then, in your project, you can add two BehaviorScripts. One to enable the sprite when the user opens their mouth, and one to disable it when they close their mouth:
Make sure that the object is disabled in the Objects panel, unless you want the object to start off visible (since the Mouth Closed event isn't called when the Lens start).
Can't wait to see what your final Lens!
Cheers,
Jonathan
Hey, I still haven't gotten it to work properly for some reason. Any other tips or could you possibly link me to a step by step process? Thanks!
Hi Rydumais,
Can you clarify what didn't work?
To create a sprite to attach the mouth, in the Objects panel press: "Add New" > Face Sprite
Then select the Sprite Binding 1 object in the Objects panel, and in the Inspector panel, set the Attach to Point to Mouth Center.
Now that your sprite is attached to the mouth, we can add our gif to the sprite. Select the "Sprite 1" object, and in the Inspector panel, select the field next to Texture. In the pop up window, choose your gif. (You can import your gif into Lens Studio by dragging it from your computer's file explorer into the Resources panel).
Now we can have it appear and disappear by using the Behavior script. Download the Behavior Script from the page mentioned above, unzip it, then drag it into the Resources panel.
Then we can create an empty object to add this script to. In the Objects panel, press Add New > Empty Object.
Then select that object, and in its Inspector panel, press Add New > Script.
In the new Script component, press "Add Script". In the pop up, choose Behavior Script.
Finally, you can set it up as in the image above!
Take a look at this sample project for an example.
Let me know if you're still having issues.
Cheers!
Jon
Hey Jon,
My gif starts to play even without opening the mouth for the first time. Then once when the mouth is opened, it works perfectly as applied. I want my gif to work only after opening the mouth and not immediately after activating it on the camera. Where did I go wrong? What should I do?
Hi Nitika,
If you select the texture in the Resources panel, in the Inspector panel, you should see a check box for "Auto Play". You can turn off this option if you don't want the gif to start playing automatically.
Cheers!
Jonathan