Script to triggering once when eyes closed

So I’ve been learning on how the FaceLandmarkTrigger works in LS. I’ve succeeded to set a custom trigger based on the eyes closed and eyes open. but the problem is that when the eyes closed, the event is just keep on triggering in every frame. I want to only make it triggering once, when the eyes is closed, until we open our mouth and close it again to retrigger it. I still have no idea how to set a Boolean from an event in LS.

In Spark, we can just set the trigger based on eye openness value or simply using the blink patch to turn on and off after hitting a certain threshold. but what happen now is that it’s like turning on and off a loop animation and sending the completed pulse in every frame.

Can someone show me how to do it in LS script?

do u trigger the animation not the blendshapes or visibility off objects?

did u try to adj min and max distance?
for me its work fine

yes, you can just try to set the cutom trigger to print message and then close your eyes. it will constantly sending trigger, which is not what i want. What i want is just one single pulse everytime it closed.

why is it necesearry you might ask. it is because i need that exact mechanics. of course we can just use after interval but that’s still just adding an interval. you can just close your eyes and it will keep triggering the event whether delayed or not. imagine if you want to make an effect that ask user to shake their head left and right to get more points, but then someone can just find out this flaws and just turning their head to the left or right all the time. so yeah, that’s what I’m trying to do. I’ve looking around to figure it out for days now, but still can’t solve it.


Blink.zip (2.3 MB)
Here I attach the simple project file and the video preview of the issue.

You can add a boolean to block the triggers so it won’t send again until the other one is triggered

var blinked = false
function sendEvent(currentValue) {
    if (script.customTrigger) {
        if (currentValue >= 1 && !blinked) {
            blinked = true
            global.behaviorSystem.sendCustomTrigger(script.maxTrigger);
        }

        if (currentValue <= 0 && blinked) {
            blinked = false
            global.behaviorSystem.sendCustomTrigger(script.minTrigger);
        }
    }
}

OMG IT WORKS! Thanks josh!

1 Like