I need help with Moving an Object with Scripts
Hello fellow Creators :)
Since ive startet created Lenses i never really used scripting because i dont understand js. But since i need scripting in the Lens im trying to create right now, im asking you for help.
So, i have a Model of a Skull imported and i want the Jaw to rotate downwards when a person opens their mouth. The Jaw is already a seperate object. If anyone has a clue please let me know.
First off, I don't think you _need_ scripting for this, but if you're trying to do it just to learn this might help:
Also note, I didn't test this code but at least it'll show you one way of doing what you want
Also also, I'm just a dude. I don't work for Snap so this might be a completely awful way of doing this lol :)
Hey, i greatly appreciate your help but i still cant get it to work.
In the beginning you said i could archive the moving jaw without scripting? If you can tell me how that works it would be great!
Have you tried to apply a Tween?
Add the tween package by clicking on the Add New > Help Scripts > Tween Manager

Now, go to your jaw object and press "add component" in the inspector and add a "Script" component.







You're going to want to attach "Tween Transform" which is in `Tween/TweenTypes/TweenTransform`
then, in your tween transform. Change the "Type" to "Rotate"
then input the start X/Y/Z and the end X/Y/Z. Make sure "Play automatically" is checked and then check to see if it works.
--
If that works, we're going to want to trigger it on MouthOpen
UNCHECK "PLAY AUTOMATICALLY": Otherwise the trigger wont work, we just wanted it checked for testing
input a "Tween Name" in the respective field on the tween component.
(note, scene object is 'none' because its attached to the component I want to move. You can drag the skull jaw into this field)
--
Now, to get the event: Go to the "Add New" > "Helper Scripts" > "Behavior"
--
Now go back to the jaw object where your tween is and "Add Component" > "Script" > "Behavior"
--
Change Trigger to "Face Event"
Then set "Event Type" to "Mouth Open"
Now, in "Response Type" you want "Run Tween"


Assign "Target Object" to your jaw object
Assign "Tween Name" to what ever you set the name to above
--
Hope that helps!