How to detect face triggers from script

Hello,

I’m trying to enable/disable a node on mouth open/close and run some custom code.

My issue here is that i’m not sure how to access the Enum described on docs that should be under Utility ( DeepAR Scripting API: Namespace: Utility.

// Use this for initialization
function onStart() {
	Debug.log("STARTED")
	Debug.log("MOUTH_OPEN_SENSITIVE: " + Utility.MOUTH_OPEN_SENSITIVE)
	Debug.log("MOUTH_CLOSED_SENSITIVE: " + Utility.MOUTH_CLOSED_SENSITIVE)

}

// Update is called once per frame
function onUpdate() {

}

// Update is called once per frame
function onTriggerStateChanged(triggerType, state, faceId){

	Debug.log(triggerType + ": " + state)
	if(triggerType === Utility.MOUTH_OPEN_SENSITIVE){
			Debug.log("MOUTH_OPEN_SENSITIVE: " + state)

	}
	if(triggerType === Utility.MOUTH_CLOSED_SENSITIVE){
			Debug.log("MOUTH_CLOSED_SENSITIVE: " + state)

	}
}

This code outputs undefined on start and some uint for face triggers. I’m not able to identify the corrects uint.

Thanks

Fixed script:

// Use this for initialization
function onStart() {
	Debug.log("STARTED")
	Debug.log("MOUTH_OPEN_SENSITIVE: " + Utility.TriggerType.MOUTH_OPEN_SENSITIVE)
	Debug.log("MOUTH_CLOSED_SENSITIVE: " + Utility.TriggerType.MOUTH_CLOSED_SENSITIVE)

}

// Update is called once per frame
function onUpdate() {

}

// Update is called once per frame
function onTriggerStateChanged(triggerType, state, faceId){

	//Debug.log(triggerType + ": " + state)
	if(triggerType === Utility.TriggerType.MOUTH_OPEN_SENSITIVE){
			Debug.log("MOUTH_OPEN_SENSITIVE: " + state)

	}
	if(triggerType === Utility.TriggerType.MOUTH_CLOSED_SENSITIVE){
			Debug.log("MOUTH_CLOSED_SENSITIVE: " + state)

	}
}

It’s Utility.TriggerType.TRIGGER_NAME
Otherwise, you did it correctly

1 Like

Thanks @jelena, maybe we could add this to the docs as an example?

1 Like

Some expanding on the scrips docs is planned, for now feel free to ask me if you get stuck or would like to see anything else documented in more detail.

2 Likes