The forum on this site is closed for new comments and posts. Continue the conversation in the new forum, and learn more here.

create bone lag

  • Hi Dale,

    For waiting for things, you should be using DelayedCallback. See example here:

    Or something similar to what Peter posted here:


    Comment actions Permalink
  • will this work for something that I want to happen every frame?

    Comment actions Permalink
  • If you want it to happen every frame, here's a event you can use for that

    Comment actions Permalink
  • My approach is to call the delayEvent in the updateEvent.

    does that sound correct? if I do that, do the variables in the updateEvent carry into the delayEvent?

    In the updateEvent, I am getting the head rotation and applying it to bone 1...and then in the delayEvent, I am matching that rotation 1 second later...

    it isn't working yet, but is that to correct approach?



    Comment actions Permalink
  • my approach doesn't seem to work...I guess if I am calling the delayedEvent.reset(1) every frame, it never gets called -- just gets pushed back


    var delayedEvent = script.createEvent("DelayedCallbackEvent");



    print("delay is over");



    function onUpdate()



    print("delay has started");



    var updateEvent = script.createEvent("UpdateEvent");


    Comment actions Permalink
  • Hello,

    You can do something like this,

    function sleep(milliseconds) {
    var start = new Date().getTime();
    for (var i = 0; i < 1e7; i++) {
    if ((new Date().getTime() - start) > milliseconds){

    var event = script.createEvent("UpdateEvent");
    event.bind(function (eventData)
    print("starting delay");
    print("delay over");
    Comment actions Permalink
  • That sleep function is working, but it is causing a huge frame rate drop. Since I am trying to update every frame with bone rotations, it immediately tanks the frame rate.

    Any other ideas?

    Comment actions Permalink
  • Yeah, i was about to edit the comment to suggest you to not use it due to fps drop.

    Let me try to figure out another way for you.

    Comment actions Permalink
  • Okay so,

    I cant believe i used this long to figure out Lens Studio have a built in "frame updated" in the script.

    I completely forgot about lens studio had that.

    var delayedEvent = script.createEvent("DelayedCallbackEvent");
    print("delay is over");
    // Start with a 2 second delay
    print("delay has started");

    Comment actions Permalink
  • I have it working, but it is steppy. How can I get the rotation to be smooth?


    // -----JS CODE-----
    // @input float delayTime = 0
    //@ui {"widget":"separator"}
    // @input SceneObject bone1
    // @input SceneObject bone2
    // @input SceneObject bone3
    // @input SceneObject root
    // @input float spinSpeed = 2.0 {"widget": "slider", "min": 0, "max": 10.0, "step": 0.01}

    var spinVal = Math.sin(getTime() * script.spinSpeed);
    var spinVal2 = Math.sin(getTime() * script.spinSpeed) * 2;

    // get the transforms
    var rootTransform = script.root.getTransform();
    var bone1Transform = script.bone1.getTransform();
    var bone2Transform = script.bone2.getTransform();
    var bone3Transform = script.bone3.getTransform();

    var rootRotation = rootTransform.getWorldRotation();
    var bone1Rotation = bone1Transform.getWorldRotation();
    var bone2Rotation = bone2Transform.getWorldRotation();
    var bone3Rotation = bone3Transform.getWorldRotation();

    var bone1RotNew = rootRotation.multiply(bone1Rotation);
    var bone2RotNew = rootRotation.multiply(bone2Rotation);
    var bone3RotNew = rootRotation.multiply(bone3Rotation);

    // bone1Transform.setWorldRotation(bone1RotNew);


    // bone1Transform.setLocalRotation( quat.quatFromEuler( 0.0, 0.0, spinVal ) );
    // bone2Transform.setLocalRotation( quat.quatFromEuler( 0.0, 0.0, spinVal ) );

    var delayedEvent = script.createEvent("DelayedCallbackEvent");
    print("delay is over");
    // Start with a 2 second delay
    print("delay has started");

    Comment actions Permalink
  • That would suggest that there are non animated textures introduced, such as you noted earlier as you can see on this page. In which case you would possibly as nicely simply use conduct scripts given that there are not any events to dam in the course of animation?

    Comment actions Permalink
  • I am using Blender 2.75. So I have an armature for a pig. I used IK to have the legs always bend (a certain direction using a pole target) to connect with the target bone. I am pretty sure this is all set upright. I have animated the location (only) of the target bone in an attempt to make a walking animation. For further details, you may visit 

    Comment actions Permalink

We're here to help! We just need a little bit of information...

What system are you using?

Have you downloaded the latest version of Lens Studio?

Please download the latest version of Lens Studio. If you still run into this issue, please come back and report it!

Is this issue causing Lens Studio to crash?

What system do you run Lens Studio on?



Follow the next steps to help us solve your issue:

  • Copy and paste this text into your TerminalCommand Window
    open ~/Library/Preferences/Snap/Lens\ Studio/ %LOCALAPPDATA%\Snap\Lens Studio Copy Text
  • Press ReturnEnter to run the command. The Lens Studio folder will automatically open
  • Prepare to upload your files: zip the "Log" Folder by right-clicking and choosing "compress."
    Locate the Log.txt file right above it.

    Attach a screenshot of the issue:



What is this most relevant to?

Please enter a brief description of your issue:

Thanks for submitting this issue.

Unfortunately, it's likely due to the operating system or hardware you're using – since they don't meet the system requirements for Lens Studio.

Still, we hear you loud and clear, and are logging the issue in case there's ever a workaround we can provide!

Minimum Requirements

Operating System: Windows 10 (64 bit); MacOS 10.11+

Hardware: Minimum of Intel Core i3 2.5Ghz or AMD Phenom II 2.6Ghz with 4 GB RAM; Intel HD Graphics 4000 / Nvidia GeForce 710 / AMD Radeon HD 6450 or better; screen resolution of 1280x768 or higher

We'll try to resolve this issue as soon as possible. Thanks for letting us know about it!

Keep an eye out for a followup email from us. We may have a couple more questions for you, or we might already have a solution to offer.

Happy creating!