Swap between 2 face index
Hello everyone!
I'm trying to make a lens with two people and when you 'tap' they switch masks &/or effects. Example: Person 1 with a hat and person 2 with a tie, and when you tap they swap and person 1 now has the tie and person 2 has the hat. I know it has to be with getindex (or that's what I think) but can't manage to do it.
Any clue how to do this? Help will be super appreciated! Thank you!!!
You want to use the .faceIndex value of a head binding component.
First import both of them,
then setup a variable to know when it's switched.
next, setup your tap event. I actually use Touch Start here because it detects taps faster.
var event = script.createEvent("TouchStartEvent");
event.bind(function(eventData)
{
// put code here
});
Then inside that you want to change the switch variable to its opposite and set the face indexes based on that:
so the full script would be:
You may want to consider this to stop the camera from flipping if spamming tap:
https://lensstudio.snapchat.com/api/classes/TouchDataProvider/
References:
Head Binding Component
TouchStartEvent
You are awesome Brandon, thank you so much!!!
Is it possible to only swap certain parts of the face, for example, swap mouth from person A with the mouth of person B?