Scene interaction helps create interest and draw attention within an effect. To create effective scene interaction, you need to understand how processing signals work and how to time them to achieve an effect with differing sets of logic.
This lesson explains:
How you can use scripts and patches to time signals and achieve an AR effect with differing sets of logic.
How to use the Swizzle patch to approach datatypes.
Learn more about processing signals to build a more interactive scene
Effects build upon change, and change often happens because of the triggers from the user. We call these triggers scene interactions. Scene interactions sustain attention to create interest. They direct people to discover different elements of a scene or explore their own environment as the AR effect augments it.
Signal processing requires creators to think about the broader context for why something happens within an effect then execute on that. To develop sustainable practices around how signals process in a scene, creators first need to know what types of data are available in Spark AR and how to use them. As a creator, you may already be familiar with the different types of data, but you might not fully understand all the ways you can change, convert or use them.
To develop a better understanding of how to approach different types of data, consider the Swizzle patch. This patch takes an input value of a vector or scalar data type and then rearranges or reorders it to whatever the user defines in the text box to the right of the Swizzle input. This functionality gives you more flexibility when you work with data types in Spark AR.
The Swizzle patch is an easy way to convert a Vector2 to a Vector3 data type. For example, if you want to use a screen pan patch to control the position of a plane in the scene, you can use the Swizzle patch to convert the Vector2 signal from the screen pan patch to the Vector3 data type necessary to control the position of the plane.
In the example below, we've entered the values xy0 in the Swizzle patch to achieve this goal. As a result, the X and Y values from the Vector2 Screen Pan patch are divided to screen size to find their screen space coordinates and then the result is passed to the 3D position property patch for the plane. Now the Vector2 passed into the Swizzle patch is now a Vector3 passed to the plane position because the swizzle has taken the X and Y properties and passed it with a third vector “0.”
Swizzle can help us understand how one patch that operates in multiple contexts at once can help us create projects quickly with logic that's shorter, easier to read and might have otherwise used many patches.
Logic is the next broad category creators work with to create scene interactions. Creators use logic frequently in AR effects to show whether something is visible at a certain point, whether a scene element should wait for a trigger before it animates or whether it should loop forever.
You can build logic in several ways but it’s often best to spend some time thinking of ways operations happen, what the results of those operations should be and how they’re connected to other results.
In the example below, we arrange a 3D sphere bouncing on the head of the user for a few seconds, then the sphere stops in place. All logic needs a cause-and-effect and a decision in-between, so we first need to determine the decision that the effect needs to make and what different conditions are presented. Let's illustrate this with the IFELSE patch.
Here the IFELSE takes a condition and two properties as outcomes. The condition of the IFELSE patch here will be a greater than one value that receives a runtime value.
When the runtime is greater than one the condition is TRUE. Now the amount of time the effect plays sets the conditional logic change.
Now we connect an animation loop and a transition loop to each to the first and second values of the IFELSE patch. We can now set the range of the transition patch to set the start and end points of one animation value.
- To develop logic that creates an engaging AR experience, it's important to know how signals are processed in Spark AR.
- Swizzle is a useful patch that can separate and reorder incoming data types which the system can then use to perform different actions.