Spatial Triggers are used when a user activates AR content by entering a specific area in relation to your location. When Custom Location AR tracking successfully starts, the camera’s Transform will update within the coordinate system of your AR objects. This means we have access to the Snapchatter’s position and rotation in respect to the rest of the AR objects within the Lens. We know how far a Snapchatter is from an AR object and when they look at an AR object. This information enables you to create in-Lens interactivity through the use of spatial triggers. Spatial triggers allow us to create interactive user experiences composed of graphics, animations, vfx, sfx, or even lines of code that are triggered when you know the Snapchatter is in a certain position or looking in a certain direction.
When creating a Custom Location Lens, begin by thinking about what you want your AR experience to do based on Snapchatters’ position and the direction from which people generally approach the location. Once that’s designed, you can bring simple pieces of geometry in the Lens Studio scene, parent those objects under the location mesh, and position them where you want to set up spatial triggers, interactions, or navigation tips. To create a successful interactive experience you will want to leverage code to check when triggers should happen. We will cover distance check and camera position check.