Scripting - Help Appreciated
Hi,
I have 4 sets of 2D images I want to change (cycling through each, one at a time), each time the user opens their mouth.
I can't get it to work for the life of me. Ideally I'd also like to get 4 sets of 2d image/lighting effect/facial retrouch but I'm really struggling and on a deadline.
This is probably a super easy fix but I'm taking forever with it and I'd appreciate if someone could advise.
My current scripting is:
// -----JS CODE-----
// @input SceneObject[] obj
createEvent(SceneEvent);
var count = 0;
script.obj[0].enabled = true;
for (var i = 1; i < script.obj.length; i++)
(
script.obj[i].enabled = false
)
function onMouthOpen(eventData)
{
count++
for (var i = 0; i < script.obj.length; i++)
(
if (count == i)
(
script.obj[i].enabled = true;
)
else
(
script.obj[i].enabled = false;
)
)
if (count == script.obj.length)
(
count = 0;
script.obj[0].enabled = true;
)
)
var event = script.createEvent("MouthOpenedEvent");
event.faceIndex = 0;
event.bind(function (eventData)
{
print("Mouth was opened on face 0");
});
Thanks, and any help is appreciated.
Hey,
Here's a example project for what you wanted.
https://drive.google.com/open?id=1-kv5781OswieD-m5JIRuCffMqoj1iRFO
I modified this script by Jonathan, and added Mouth Opened Event.
https://support.lensstudio.snapchat.com/hc/en-us/community/posts/115020451643-Make-Things-Change-on-Tap
https://lensstudio.snapchat.com/api/classes/MouthOpenedEvent/
Let me know if you need help with anything else.
Didn't read the part where you also wanted " like to get 4 sets of 2d image/lighting effect/facial retrouch"
Let me know if you want me to add that into the script as well.
Oh wow, I really appreciate the help - that will be amazing to learn from!
If you could do it so I could have 4 folders (?) to put different elements in, to be cycled through when the user opens their mouth, that’d be awesome.
Thanks again.
Oh wow, I really appreciate the help - that will be amazing to learn from!
If you could do it so I could have 4 folders (?) to put different elements in, to be cycled through when the user opens their mouth, that’d be awesome.
Thanks again.
Hello Again,
I modified the script to what you wanted.
I created 4 head binding, which the first one is enabled, and when person opens their mouth, the previous one gets disabled, and the next one gets enabled.
You can just drag in stuff into 1, 2, 3 or 4.
https://drive.google.com/open?id=1CB3Zv_eQoGAPg4ePk7fSJ1njju0SbUij
Let me know if i can help you with anything else.
happy creating.
Thank you so much. You’re such a huge help! I will let you know if I get any issues as I’m out at the moment.
I’m doing this to attach 2d illustrations of hair to the users head. Can you advise of any better way to create fake hair/wigs?
All the best.
Thank you so much. You’re such a huge help! I will let you know if I get any issues as I’m out at the moment.
I’m doing this to attach 2d illustrations of hair to the users head. Can you advise of any better way to create fake hair/wigs?
All the best.
My pleasure!
Lens Studio made a beautiful tutorial for such things, just adjust it a little bit.
https://www.youtube.com/watch?v=6SYBmg8O6Fg
Let me know if i can help you with anything else.
Thanks so much again, I'll definitely be trying that for my next project.
I'm having issues with the folders however - I can't change the head bindings you've created at all it seems, and so I can't get the 2D images to pin properly onto the head. Could you advise?
You're a lifesaver!
Hi Rich,
I'm glad n-mikael was able to help! It looks like your next question pertains specifically to his file, but please let us know if we can assist you any further on our end.
Cheers,
Neha
Hello Rich,
Can you tell me more? like, are you dragging the 2d image into a head binding?
Can you take a video or a screenshot?
It'd help me to understand what you mean.
Hey! I want it to be bound like the headbands/ears in the 2D Image template I believe, so it's a bit smoother. Even after importing that in, I cannot move the blue dot to move the binding in the 2D image view, a green dot appears in the center. I can't move any of your bindings on the 2D layer view...
In this image you can't see my mouse but I'm trying to drag the blue button and it's locked.
Thanks again
I have no idea how you got that custom point up in the Attach to point because i don't get that up.
I've got a bit of a work around going but having some issues elsewhere... Do you have an email or something we could discuss easier on? Thanks!
Sure thing, if you got discord, add me.
Let me know what your name is so i can find you easier.
Sorry for the delay, just dropped you a request! Think I remembered it right :P
May i know what's yours? I've got over 700+ pending requests so it would be hard to find ya
:)