How to copy rotation along specific axis


Hi, am looking for a script which allows to copy rotation but only along the specified axis (x).

For context, am taking the rotation of a head binding, and applying that to an empty which I have parented some image layers to, and only want it to rotate on the axis facing the camera.


  • سعد الفريدي
    سعد الفريدي Posts: 447 🔥🔥🔥

    Have you searched for a template within Lens Studio that does this!

  • Chunkeyninja

    There's hundreds of templates, any specific suggestion?

  • Bakari Mustafa
    Bakari Mustafa Posts: 178 🔥🔥🔥
    edited January 2023 #4

    @Chunkeyninja Here is a script that you can use to copy the rotation of a head binding along the x-axis to an empty object with image layers parented to it:

    // Replace "headBinding" with the name of your head binding object
    // Replace "emptyObject" with the name of your empty object
    const headBinding = Scene.getObjectByName("headBinding");
    const emptyObject = Scene.getObjectByName("emptyObject");
    // Get the x-axis rotation of the head binding
    const xRotation = headBinding.getTransform().rotation.x;
    // Set the x-axis rotation of the empty object
    emptyObject.getTransform().rotation.x = xRotation;