How To Make an Object Move With Device's Rotation in Lens Studio
Lens Studio

How To Make an Object Move With Device's Rotation in Lens Studio

If you wanted one of the objects in your lens to rotate when the user moves their phone, to give a more natural look, without actually moving the object, here's a cool method I figured out on how to do that! This effect was used in my "Art Show" lens, you can try here.

The first step is to duplicate the camera and make the second camera a different layer. Then click the "Add Component" button, add a "Device Tracking" component, and set the tracking mode to rotation. It should look like this:



Then, add your 3D object to the scene. Click your object mesh and in the inspector, click "Add Component" and choose "Look At." Then, set the target to your second camera, with the device tracking. Lastly, set the mode to "Look at Direction." The inspector tab on your 3D object should look like this:



To test this effect, I find it's best to switch from "Multimedia Preview mode" to "Interactive Env" and right-click around to simulate the user's device moving. You should notice that your object stays in place and rotates along with the device.

Also, you can download the template I made for this effect by clicking here, and replacing the cube mesh with your own model!