Tap plane to position object
-
*bump*
I don't need exact instructions, but can anyone tell me is this even possible? :) Thanks!
Comment actions -
Hi Steven,
The easiest way to do this is to start with the WorldObjectController object disabled in the Objects panel, and enable it through script on SurfaceTrackingReset event. Here's a simple script that will do just that:
//@input SceneObject target
script.createEvent("SurfaceTrackingResetEvent").bind(function(){
script.target.enabled = true;
});Just create a new SceneObject, add this script onto it (bound to Initialized event) and set "target" to the WorldObjectController object. And make sure the WorldObjectController object is disabled in the Objects panel.
Note that this event doesn't fire in Lens Studio, only on device. So if you want to test it in Lens Studio, you can also add this code to the end of that script:
// For testing in Lens Studio
script.createEvent("TapEvent").bind(function(){
if(global.scene.getCameraType() == "back"){
script.target.enabled = true;
}
});Hope this helps! Let me know if you have more questions about it.
Thanks,
JacobComment actions -
Hi Jacob,
Thanks a lot for your help!
Can you please elaborate more on the "set "target" to the WorldObjectController object" part? Do I set it inside the script, too? Because I see no other interface element to do it.
Sorry for the newbie questions, I'm very new to Lens studio.
Thanks again!
Comment actions -
Hi Steven,
- Create a blank script by clicking Add New > Script in the Resources panel
- Select the script, paste the code into the text editor in the Inspector panel and click Apply changes
- Add a new SceneObject by clicking Add New > Empty Object in the Objects panel
- Select the new object and add the script to it by either A) Dragging the script from the Resources panel into the Inspector panel, or B) Clicking "Add Component" in the Inspector panel, clicking Script, clicking Add Script, then selecting your script.
- You should now see this in the Inspector panel:
- Click in the box that says "None" next to "Target" and select the object you're trying to hide (WorldObjectController if you're using one of the surface object templates.)
- Make sure the object you want to hide is disabled. You can do this in the Objects panel by unchecking the box to the right of the object's name.
Let me know if you need more help!
Comment actions -
Hi Jacob,
That's exactly what I did the first time, but I can't seem to get the "Target" field to appear:
Comment actions -
@Jacob: Actually, nevermind, I started a new project from zero and now I see the Target field. :) Works like a charm.
Thanks a lot for your patience, and especially for the help!
Comment actions
Please sign in to leave a comment.
Have a comment?