Custom trigger - User looking up
-
Hey I.A,
A script perhaps could do what you're looking for "detect if a user is looking up" the same way it can detect when someone is opening their mouth or closing their eyes. it's going to be tricky because there are only certain triggers available right now.
Comment actions -
Hey A.I,
I found the script you're looking for just copy and paste these two scripts and it should work fine
Comment actions -
// FaceTriggerAnim.js
// Version: 0.0.2
// Event: Lens Initialized
// Description: Plays an animation layer, sound, sprite, on trigger// @input string AnimationTrigger = MouthOpenedEvent { "widget": "combobox", "values": [ { "label": "Brows Lowered", "value": "BrowsLoweredEvent" }, { "label": "Brows Raised", "value": "BrowsRaisedEvent" }, { "label": "Brows Returned To Normal", "value": "BrowsReturnedToNormalEvent" }, { "label": "Face Found", "value": "FaceFoundEvent" }, { "label": "Face Lost", "value": "FaceLostEvent" }, { "label": "Kiss Finished", "value": "KissFinishedEvent" }, { "label": "Kiss Started", "value": "KissStartedEvent" }, { "label": "Mouth Closed", "value": "MouthClosedEvent" }, { "label": "Mouth Opened", "value": "MouthOpenedEvent" }, { "label": "Smile Finished", "value": "SmileFinishedEvent" }, { "label": "Smile Started", "value": "SmileStartedEvent" }, { "label": "Touch Start", "value": "TouchStartEvent" }, { "label": "Touch End", "value": "TouchEndEvent" }, { "label": "Tap", "value": "TapEvent" } ] }
// @input int faceIndex = 0// @ui {"widget":"separator"}
// @ui {"widget": "group_start", "label": "3D Anim Control"}
// @input Component.AnimationMixer AnimationMixer
// @input string LayerName
// @input int animationPlayCount = 1 {"label": "Play Count", "min":-1, "max":99999, "step":1} // How many times to play the animation, -1 for infinite
// @ui {"widget": "group_end"}// @ui {"widget":"group_start", "label":"2D Anim Control"}
// @input Component.Image[] play2dSprites {"label": "Play Animations"}
// @input int texturePlayCount = 1 {"label": "Play Count", "min":-1, "max":99999, "step":1}
// @input float texturePlayOffset = 0 {"label": "Play Offset", "min":0.0, "max":99999.0, "step":1}
// @ui {"widget":"group_end"}// @ui {"widget":"group_start", "label":"Sound Control"}
// @input Asset.AudioTrackAsset[] playAudios {"label": "Play Sounds"}
// @input int audioPlayCount = 1 {"label": "Play Count", "min":-1, "max":99999, "step":1}
// @ui {"widget":"group_end"}// @ui {"widget":"separator"}
// @input float TriggerDisableTime = 0
var triggerStartTime = getTime() - script.TriggerDisableTime;
// What happens when event is triggered
function onTriggered()
{
print("FaceTriggerAnim: " + script.AnimationTrigger + " triggered");// Called when animation ends
function animationCallback()
{
script.AnimationMixer.setWeight(script.LayerName, 0.0);
}// Play animation layer with sound (if available)
if (script.AnimationMixer && script.LayerName)
{
script.AnimationMixer.startWithCallback(script.LayerName, 0.0, script.animationPlayCount, animationCallback);
script.AnimationMixer.setWeight(script.LayerName, 1.0);
}for (var i = 0; i < script.play2dSprites.length; i++)
{
if (script.play2dSprites[i]
&& script.play2dSprites[i].mainPass.baseTex
&& script.play2dSprites[i].mainPass.baseTex.control
&& script.play2dSprites[i].mainPass.baseTex.control.play)
{
script.play2dSprites[i].getSceneObject().enabled = true;
script.play2dSprites[i].mainPass.baseTex.control.play(script.texturePlayCount, script.texturePlayOffset);
}
}for (var i = 0; i < script.playAudios.length; i++)
{
if (script.playAudios[i])
{
var audioComponent = getAudioComponentForTrack(script.playAudios[i]);
audioComponent.play(script.audioPlayCount);
}
}
}// Trigger an action if not in cooldown period
function triggerCallback()
{
if (getTime() >= triggerStartTime + script.TriggerDisableTime) {
triggerStartTime = getTime();
onTriggered();
}
}// Setup the audio component if audio track defined
function getAudioComponentForTrack ( audioTrackAsset )
{
var trackName = audioTrackAsset.name;if (!global.ftAudioComponents)
{
global.ftAudioComponents = {};
}if (!global.ftAudioComponents[trackName])
{
var audioComponent = script.getSceneObject().createComponent("Component.AudioComponent");
audioComponent.audioTrack = audioTrackAsset;
global.ftAudioComponents[trackName] = audioComponent;
}return global.ftAudioComponents[trackName];
}// Allow fullscreen tapping if trigger is touch based
if (script.AnimationTrigger == "TouchStartEvent"
|| script.AnimationTrigger == "TouchStartEvent"
|| script.AnimationTrigger == "TapEvent")
{
global.touchSystem.touchBlocking = true;
global.touchSystem.enableTouchBlockingException("TouchTypeDoubleTap", true);
global.touchSystem.enableTouchBlockingException("TouchTypeSwipe", true);
}var event = script.createEvent(script.AnimationTrigger);
event.faceIndex = script.faceIndex;
event.bind(triggerCallback);Comment actions -
This Second Script Is if you want the Hints/ Popup words to show on the screen when someone uses the lens you make for example it says "look up"
// ShowHint.js
// Version: 0.0.2
// Event: Any Event
// Description: Shows a hint to the user
// @input string hintId {"widget":"combobox","values":[{"label":"Aim camera at the sky","value":"lens_hint_aim_camera_at_the_sky"},{"label":"Blow a kiss","value":"lens_hint_blow_a_kiss"},{"label":"Blow a kiss voice changer","value":"lens_hint_blow_a_kiss_voice_changer"},{"label":"Come closer","value":"lens_hint_come_closer"},{"label":"Do not smile","value":"lens_hint_do_not_smile"},{"label":"Do not try with a friend","value":"lens_hint_do_not_try_with_a_friend"},{"label":"Draw with your finger","value":"lens_hint_draw_with_your_finger"},{"label":"Find face","value":"lens_hint_find_face"},{"label":"Find image","value":"lens_hint_find_image"},{"label":"Find marker","value":"lens_hint_find_marker"},{"label":"Find snapcode","value":"lens_hint_find_snapcode"},{"label":"Kiss","value":"lens_hint_kiss"},{"label":"Kiss again","value":"lens_hint_kiss_again"},{"label":"Look around","value":"lens_hint_look_around"},{"label":"Look down","value":"lens_hint_look_down"},{"label":"Look left","value":"lens_hint_look_left"},{"label":"Look right","value":"lens_hint_look_right"},{"label":"Look up","value":"lens_hint_look_up"},{"label":"Make some noise!","value":"lens_hint_make_some_noise"},{"label":"Move your head","value":"lens_hint_move_your_head"},{"label":"Nod your head","value":"lens_hint_nod_your_head"},{"label":"Now kiss","value":"lens_hint_now_kiss"},{"label":"Now open your mouth","value":"lens_hint_now_open_your_mouth"},{"label":"Now raise your eyebrows","value":"lens_hint_now_raise_your_eyebrows"},{"label":"Now smile","value":"lens_hint_now_smile"},{"label":"Open your mouth","value":"lens_hint_open_your_mouth"},{"label":"Open your mouth again","value":"lens_hint_open_your_mouth_again"},{"label":"Open your mouth voice changer","value":"lens_hint_open_your_mouth_voice_changer"},{"label":"Pick a face","value":"lens_hint_pick_a_face"},{"label":"Pick a photo","value":"lens_hint_pick_a_photo"},{"label":"Pick an image","value":"lens_hint_pick_an_image"},{"label":"Raise your eyebrows","value":"lens_hint_raise_your_eyebrows"},{"label":"Raise your eyebrows again","value":"lens_hint_raise_your_eyebrows_again"},{"label":"Raise your eyebrows or open your mouth","value":"lens_hint_raise_eyebrows_or_open_mouth"},{"label":"Raise your eyebrows voice changer","value":"lens_hint_raise_your_eyebrows_voice_changer"},{"label":"Rotate your phone","value":"lens_hint_rotate_your_phone"},{"label":"Say something","value":"lens_hint_say_something"},{"label":"Smile","value":"lens_hint_smile"},{"label":"Smile again","value":"lens_hint_smile_again"},{"label":"Smile voice changer","value":"lens_hint_smile_voice_changer"},{"label":"Swap camera","value":"lens_hint_swap_camera"},{"label":"Tap a surface","value":"lens_hint_tap_a_surface"},{"label":"Tap ground to place","value":"lens_hint_tap_ground_to_place"},{"label":"Tap surface to place","value":"lens_hint_tap_surface_to_place"},{"label":"Tap the ground","value":"lens_hint_tap_ground"},{"label":"Tap!","value":"lens_hint_tap"},{"label":"Tilt your head","value":"lens_hint_tilt_your_head"},{"label":"Try it with a friend","value":"lens_hint_try_friend"},{"label":"Try it with your rear camera","value":"lens_hint_try_rear_camera"},{"label":"Turn around","value":"lens_hint_turn_around"},{"label":"Voice changer","value":"lens_hint_voice_changer"},{"label":"Walk through the door","value":"lens_hint_walk_through_the_door"}]}
// @input float showTime = 2.0 {"label": "Show Time"}
// @input float delayTime {"label": "Delay Time"}
// @input bool showOnce = true {"label": "Show Once"}
// Initialize hints
if( !script.initialized ) {
// Create the hint component
script.hintComponent = script.getSceneObject().createComponent( "Component.HintsComponent" );
// Initialize done
script.hintShown = false;
script.initialized = true;
}
// Show the hint
showHint();
function showHint() {
// Only show hint if it hasn't been shown, if allowing multiple times
if( !script.hintShown || !script.showOnce ) {
// Create a delayed callback to show the hint
var delayEvent = script.createEvent( "DelayedCallbackEvent" );
delayEvent.bind(function(eventData) {
print( "Showing Hint: " + script.hintId );
script.hintComponent.showHint(script.hintId, script.showTime);
})
delayEvent.reset(script.delayTime);
// Mark hint as shown
script.hintShown = true;
}
}
Comment actions -
Comment actions
Please sign in to leave a comment.
Have a comment?