If you've imported a 3D object with 2 or more animations baked into the file, you can use patches to easily switch between these animations in response to user interaction.
For very simple animated effects, use the animation playback controller.
Each of the animations that you want to play in your effect will need to be assigned to a separate animation playback controller. Find out more about creating animation playback controllers and assigning animations to them.
There are lots of interaction patches in Spark AR Studio. They detect interaction from the user, and output signals that can drive the rest of the graph you build in the Patch Editor.
For these effects, you'll need an interaction patch that creates a boolean signal (a signal that's either on, or off). For example, the Mouth Open, Screen Tap and Happy Face patches.
Start by creating the animation playback controllers:
Select the 3D object that you want to animation in the Scene Panel, and click the arrow next to Animation in the Inspector to create a patch representing the property we want to affect with this graph.
Next create 3 patches in the Patch Editor. Right-click, and select:
If Then Else can accept different data types. Change the data type to Animation Data using the dropdown at the bottom of the patch.
Next connect the patches. Connect:
So, each time the screen is tapped, a switch is turned on or off. When it's on, the animation connected to the Then port will play, when it's off, the animation connected to the Else port will play.
The graph should look like this:
If you select Simulate Touch in the Simulator, clicking the screen will simulate someone tapping on a device:
“Kako” by manoeldarochadeoliveira is licensed under CC BY 2.0
This time, use the the Counter and Option Picker patches, instead of Switch and If Then Else. You can create both of these by right-clicking in the Patch Editor to open the menu.
Remember to set the Maximum Count in the Counter patch. In the example below we set it to 3, to count through 3 animations and then start again.