Custom component script

I found that we can adjust the weight of the component via a script, but have had no luck adjusting it.
It doesn’t change anything when I try to 0,1 or 1 in weight =(

https://docs.snap.com/lens-studio/references/guides/general/custom-component/#using-custom-components-in-scripts

//@typename posConst
//@input posConst constraint

// Set influence weight of the constraint to 0.5
script.constraint.weight = 0.5;

Sounds like a great practice for when people will be able to build custom component and that we want to prevent them from using too much space.

I wish there was a logic like that to prevent Chrome from binge eating my laptop sometimes

1 Like

It’s not working because you are pulling that example from the position constraint component. The ML components don’t have the same properties. You can see the properties of an object by printing them out like this:

//@typename Baby
//@input Baby baby
print(Object.keys(script.baby))
script,sceneObject,faceCropTexture0,faceCropTexture1,faceIndex,material,model,event0

Maybe you can do something with the model property, which is an MLAsset. There might also be some parameters on the material that you can adjust.

1 Like

oh, I’m surprised :smiley:

In the public version, you don’t have the ability to change much property of ML
just render order and face index :frowning:

There is probably a reason for that, haha. I’m not sure if changing any of those other properties will have negative effects, but it’s worth some experimentation.