Block all possible triggers for an interval of time, after an initial face event is triggered?
Hey Lens Studio Creators,
I have a lens that triggers on 3 different face events: Brows Raised, Mouth opened, or Smile started. Then depending on which face event is triggered, a corresponding 2D sprite animation is played. However, if in the middle of the animation playback for whatever the user triggered, How do I block the other triggers until it plays all the way through. So, a person can't open their mouth and have it switch over to the other animation?
For example, if the user raises their eyebrows the animation begins playing, but if the user then opens their mouth in the middle of that first animation playback, it'll jump to the 2nd animation playback. Is there a way to tell lens studio to not allow triggers while 1 animation playback is occuring?
Sorry for any confusion, this is difficult to explain with words.
- George
Hey Georgie,
How are you triggering these events? Are you using the behavior script? The Trigger template? Or are you using your own custom script?
Ben
Hey Ben,
I’m using the behavior script to trigger all events. I don’t have any java script programming background, so I’m using templates as a starting point and building my lens studio project from there. I was able to figure out using the behavior script, but found it limiting in certain scenarios. Any advice on how to block other triggers until the animation plays in its entirety?
Yeah, unfortunately, this would require a little bit of custom scripting. What you could do is make each of the triggers set to Allow Once, so they will only happen one time. The downside to this is that the users wont be able to trigger them over and over again, they will have to re load the lens each time.
Ben, I hear you on the “Allow once” behavior script option, thanks for all this information! How long would it take me to learn enough coding skills to make a custom script? Days, weeks or months? I know you do YouTube tutorials do you have anything on this topic that could help me?
Hi Georgie Boy, Ben Knutson,
Jacob made a great example on how to deal with multiple triggers and making sure they don't collide here: https://lensstudio.zendesk.com/hc/en-us/community/posts/360042603771/comments/360004824051
Alternatively, you can have an object for each face trigger, and then have an additional behavior script to enable/disable the other ones.
For example: let's create two objects: one to hold Brows related behavior scripts, and the other to hold mouth opened related behavior scripts:
First we can create a behavior script that fires all other behavior:
Then on that same object we can do some action on this trigger, in this case print a message:
Finally, we'll create two more behavior scripts to disable the Mouth Listener object when brows is raised, and re enable it after some delay so that the Mouth Trigger won't activate if brows were just raised.
Can't wait to see what you both come up with!
Cheers,
Jon
Hey Jonathan,
If I'm understanding this correctly, I should be disabling the scene object that holds the behavior scripts, so that when any of the triggers is activated, it disables the other 2 scene objects that hold behavior scripts that allow triggers to interrupt what the user is currently watching?
I think disabling the behavior scripts for the other triggers while a selected trigger is active could work, although I'm having trouble figuring out how to break out the different scripts on different scene objects, to make this method work.
Thanks for your thoughts,
- George
Hey Jonathan,
**Update** Your method worked! I was able to de-collide the various face triggers, by turning off the different script objects that held the behavior scripts I wanted to temporarily inhibit. However, I don't fully understand the "send custom trigger" response type. Why do I need to send the custom trigger at all? I've tried it without that step and it doesn't work.
Why can't I select:
Trigger: Face Event
Event Type: Mouth Opened
why does it need to be the "on Custom Trigger": "onMouthOpen" I'm unclear what the difference comes down to. Additionally, do behavior scripts get run in the order they are listed in the inspector panel?
- George