No scripts working
Hey all, I've tried following several online tutorials and im not able to get ANY scripts to work. I'm using widows 10, Lens Studio 3.0.0 released 2020-06-11. Yes, i reinstalled and rebooted.
IDEALLLY, id like to use scripting to get a position from a head binding. I found this one online, let me know if there is a better one:
var obj = script.getSceneObject()
var o = obj.getTransform().getWorldRotation()
var event = script.createEvent("UpdateEvent");
event.bind(function(eventData) {
obj.getTransform().setWorldRotation(o)
});
Hi, TheSpikenstein!
To make this work you need to create a New- > Head Binding in your project
Then drag and drop this script from the Resources panel into Inspector panel with Head Binding selected
To see something happening please change script like this :
You should see output in the Logger Panel
Let me know if that works!
If you want to add references to other sceneObject to your script please check out Custom Script UI section in Scripting Guide
Let me know if that helps!
Best
Olha
hey Olha,
Thanks for the quick reply. I Did as you said
1. added head binder
2. added script
3. applied script
4. pasted script
Logger does not display any coodinates. see pic.
ALSO, how would i get this information onto a mesh once its obtained?
Hi! Do you have a face on a preview video?. Script is attached to the head and head is not detected.
Select Window-> Panels -> Default layout and pick any picture or video with a face on a preview panel.
Now you should see script working.
But let's put it onto another object to prevent this behavior:
I removed script from the head binding, and attached it to the empty object
Modified script like this :
You can see that script has two inputs now. So go on and assign objects to the fields (by dragging and dropping)
My project is here
Hope this helps!
hey Olha,
Thanks for the example scene and Yes it works in your file...
But i cannot build it from scratch.... The camera is on, and i can attach meshes to the face tracker.
The ONLY difference i can see bewteen our scenes is your Script appears in the the OBJECTS panel. I dont see how to add it there. Tried dropping in on the HeadBinding, on the Sphere in both objects panel AND in Inspector Panel... I Just dont see how to "activate" the script.
your example
Mine not working
Hi!
In the Objects Panel press "+" and select Empty Object
With newly created object selected drag the script onto Inspector panel
That makes sense, thanks...
BUT, the problem is after adding Empty Object and then dropping the script on it... The Empty Object DOES NOT have the inputs.
I CAN do this in your scene. But not from one i build from scratch.
PS. this is the case of all scripts even print("hello")
Is there an "activate scipt" button somewhere im missing???

Looks like changes in a Script are not saved.
Click on the script editor window and press Ctrl (Cmd) + S to save.
The circle near the script tab should disappear
Hope this is it!
Olho.... You ARE THE MAN.
Where the hell is that in the bloody documentation??? :(
I Promise to give you personal shout out on my first lens.
Thanks again for all your help, you deserve a raise.
Glad it worked! Thank you!
Actually this guide has step by step instructions on creating a first script https://lensstudio.snapchat.com/guides/scripting/scripting-example/ . I'll make sure to add note about saving
Also you can try looking into our template video guides to get the general idea of how Lens Studio works:)
https://lensstudio.snapchat.com/templates/
Best
Olha
Hii buddy
1. added head binder
2. added script
3. applied script
4. pasted script
Logger does not display any coodinates. see pic.
ALSO, how would i get this information onto a mesh once its obtained?
hi, Mamoona khalid!
Unfortunately the is no picture added. Do you mind sending your code or explain what are you trying to print out?
If you are assigning some script to the scene object with Head Binding component - make sure you are testing the lens on a preview that has a head in a frame.
Best
Olha