Hi, the World tracking option is a fantastic addition! I was wondering, if it is possible to get the user position, relatively to the world or 3D object, once it is placed? For example, to trigger events when the user is close from specific points? Anyways, great job! Cheers.
Absolutely! The “user” in Zappar is just
Z.camera so you can stick a
TriggerRegion relative to the world anchor, and a simple visible false, enabled true plane object relative to
Z.camera with a tag set to the
triggerTag of the trigger region.
You can then get callbacks with the local position of the trigger in the world every frame.
The latest Zappar app includes a way of removing this frame delay, just set the
updatePhase property of the trigger region to
Z.FramePhase.after_early_updates, which will calculate the trigger positions after early updates for the new frame (including things like gyro and tracking updates).
This is a bit hidden right now (it’s not exposed in Studio’s property list yet and not documented). You can just set it in a script node, only needs to be done once:
Thanks Simon! It’s working fine
But regarding the frame delay, the ‘zappar’ keyword is not found and fires a script error.
Oops, sorry. You can just use
Z. now it’s in the typescript definitions in Studio. I copied and pasted from an earlier test scene I was working on. I’ve edited the post above now for anyone new to the thread.
Perfect! Thanks again!
I’m sorry to ask, but would it be possible to elaborate a little on this procedure? I have been trying to do this for a while without success. I placed a plane in the area where I want action to trigger (in my case, display a plane with text materiel on root) when user enters plane. I used ACTION in properties “ON TRIGGER REGION ENTER” and sert a state that will make a plane on root visible, but this does not seem to work. I’m not clear on how to set-up a trigger region. Where could I find this info?
Thank you for your help
OK! I figured it out! Didn’t understand that I had to first define a trigger region from NEW menu! Duh. Sorry for misunderstanding
And I have just see this thread: Sipsmith Portal - Inspiration Project
With everything inside…
But I still have a question: how can we get the coordinates of the Z.camera relatively to the world? Z.Camera.position() returns always (0,0,0)… Triggers are great, but I would like also be able to control element with their distance from specific points.
In Zappar we don’t have a single coordinate system shared by everything in the scene. There are instead different “spaces” - so we refer to
Z.camera as “camera space”, and target finders and world anchors define their own spaces.
Z.camera.position() is always [0,0,0] as it is the origin of the camera space.
This is where
TriggerRegion comes in. You can use them in the same space if you want, so you can have a
Z.camera and an object node defined as a trigger also relative to
Z.camera. However their real utility is when the
TriggerRegion and trigger objects are in different “spaces”, as this allows you to map coordinates of the object from the space where it is defined to the space where you want it.
In the case of user position, you want your trigger object
Z.camera and your
relativeTo a group in the world tracking space. If you have the shape of the TriggerRegion set to
none then the trigger will always be inside the active volume of the
TriggerRegion. That means every frame you can retrieve the position of the user in world space with an event handler.
I’ve put together a quick demo scene to show how this works:
WorldTrackingTriggerRegionDemo.zpp (4.6 KB)
Hold down on the screen to make a trail of planes in world space. It’s pretty fun
So the example above shows how to get the exact position of trigger objects in the TriggerRegion’s coordinates. However if all you want to do is have something happen when the user enters a certain part of the world, that can be done without any code at all, just using actions “on trigger enter” and “on trigger leave”.
Here’s a minimal example using the standard ground placement subsymbol:
WorldTrackingTriggerRegionActions.zpp (1.1 MB)
You need an object relativeTo Z.camera, with a tag set (something like ‘cameraTrigger’ is sensible). Then add a TriggerRegion anywhere you want to take an action when the user enters or leaves, and set the
triggerTag property to the same tag you added to the object that you want to use as the trigger.
Thank you so much Simon, for these precisions! Your demo is very useful and opens a lot of opportunities for cool apps! - Too bad Little Thumb didn’t get Zappar!
This is SO COOL!!