Articles
Video Calling and Group Effects
Multipeer Patches

Multipeer Patches Overview

Use multipeer patches to build effects that can be applied to a group on a video call.

For example, you could create an effect where one participant tapping the screen triggers something else to happen in other instances of the effect, like changing the other participants’ background. This type of effect is called a group effect in Spark AR Studio.

Group effects:

  • Run separately on each participant’s device.
  • Can communicate with other instances of the effect, within the same video call.

If you're familiar with scripting, you can also use the MultipeerModule API to build group effects.

Available Patches

There are 2 multipeer patches and they're available in the Multipeer section of the Patch Menu. You can use these patches to make group effects, alongside 3 Utility patches: Pulse Pack, Pulse Unpack and Throttle.

Multipeer patches

Name Description
Multipeer Send

This patch works with the Multipeer Receive patch to send information between instances of an effect used by different video call participants. To send multiple pieces of information as a message, use the Pulse Pack patch to pack and input information into this patch.

Multipeer Receive

This patch works with the Multipeer Send patch to send information between instances of an effect used by different video call participants. Messages can only be sent between peers — you can’t send a message to yourself.

Utility patches

Name Description
Pulse Pack

Pack and send information using a pulse signal. Must be connected to a Pulse patch.

Pulse Unpack

Unpack information from a packed pulse signal. Use this patch with the Pulse Pack patch.

Throttle

Throttle a given event to a specified duration.

How the multipeer patches work

These patches let you package numerical, boolean, text or Vector2, 3, 4 data from one instance of an effect into a message to send to another instance.

The message is sent on a specified channel. You can have multiple message channels within the same effect.

Each message is made up of the data to input plus a key, which is a textual representation of the data being sent.

Sending the message

In the graph below, when the screen is tapped, the Pulse Pack patch packs information and sends it to the Multipeer Send patch.

In this instance the information is someone’s name represented by the FirstName key. GameTopic is specified in the Multipeer Send patch. This is the channel the message will be sent on.

Patch graph sending a message to the multipeer patch

Packaging more data into the message

For each additional piece of information you want to package into the message, connect a separate Pulse Pack.

In the example graph below, we added two Pulse Pack patches because we want to send FirstName data and Position data on the mouth.

Patch graph sending first name and position data to the multipeer patch

Once the message is sent, it’s received by another instance of the effect via the Multipeer Receive patch. The Multipeer Send and Mutipeer Receive patches transmit data without a connecting cable, as long as the same Topic is specified.

Keep in mind that you can’t send a message to yourself. You need to have both Spark AR Player and Spark AR Desktop player open when building your effect, in order to test how different instances of your effect communicate.

Receiving the message

When the message is received you can unpack it with a Pulse Unpack patch and connect to further logic to trigger something in your effect. In the image below, the Pulse Unpack patch unpacks the message containing someone's name (Lucy) and sends this information to a Value patch.

Patch graph unpacking a message containing first name data

Testing

When you’re building your group effect, you can try the effect on more participants in Spark AR Player for Desktop.

Example

In the example below, we’re previewing a group effect in Spark AR Desktop player, to test how it would appear on a video call with 3 participants. 1 of the participants is represented by the Simulator in Spark AR Studio. This participant is labeled User. When the User or another participant blows a kiss, we see a heart appear on the device screen of Participant 1 and Participant 2, and disappear again after 2 seconds.

We created this logic with the patch graphs below:

Patch graph that makes a heart appear when one participant blows a kiss

Sending the message

The top patch graph in the Kiss Event and Send Message box counts how many kisses are detected and sends this message on the SendHeartTopic channel.

We did this by connecting:

  • The Face output of faceTracker0 to the Kissing Face patch.
  • The Kissing Face patch to the Pulse patch.
  • The Turned On output of the Pulse patch to the Increase input of the Counter patch and the Event input of the Pulse Pack. We changed the data type in the Pulse Pack to a Number.
  • The Pulse Pack to the Multipeer Send patch.

Finally we entered:

  • KissCount as the Key in the Pulse Pack patch.
  • SendHeartTopic as the Topic input in the Multipeer Send patch.

Receiving the message and making the heart visible

The patch graph in the Message Received and Heart Visible box makes a heart appear each time this message is received. And then disappear again after 2 seconds.

We did this by connecting the Multipeer Receive patch to:

  • The Turn On Input of the Switch patch.
  • The Delay patch.
  • The Pulse Unpack patch.

We then entered:

  • KissCount in the Key input of the Pulse Unpack patch.
  • 2 in the Duration input of the Delay patch.

Finally, we connected:

  • The Delay patch to the Turn Off input in the Switch patch.
  • The Switch patch to a Visible property patch for the Heart object.

The Pulse Unpack patch is not triggering anything to happen in the effect, it’s simply unpacking the message to retrieve a number for the last kiss count.

You could connect this patch to other patches to make something else happen based on the number of kisses detected, adding more complexity to this effect.

The template

To help you get started using patches to build a group effect, we've provided the Send to a Group template in the Spark AR Studio Welcome Screen.

We walk you through the template in this article.

Creator days workshops

In these 2 group effect workshops, expert creators demonstrate how to use Multipeer patches and the Multipeer API to exchange data in a group effect.Rewatch the sessions to learn how to:

  • Send messages or signals to participants on a call.
  • Send multiple streams of message channels to send different messages.
  • Use the Multipeer patches and API and the State.
  • Record a group effect.