Skip to content

Remote Controls

The A/B testing and Remote Configurations features allow you to customize the behavior of your app based on different conditions or User Segments. Remote Variables can be a powerful tool during feature development and managing live apps by serving settings that are managed remotely.

A/B Testing

An A/B test is a configuration that randomly returns one of several variants to the application. This allows developers to test different variants of a feature, setting, or content to see which performs better. The test can involve multiple user groups, each receiving different versions of the variable to compare performance or user engagement.

For example, you could use an A/B Test to select a different layout for your main menu. After one hundred players have seen each variation, you can analyze the results on the Dashboard to see which one leads to more feature usage and longer user retention.

Remote Configurations

A Remote Configuration refers to a set of rules for returning a specific Remote Variable to the application. You can use these configurations to modify gameplay mechanics, user experience, or performance-related aspects dynamically.

For example, you could use a Remote Configuration to control guidance in a VR training experience. After a couple weeks in which employees are guided through a process, the guidance in the VR app could be turned off. You could then use the Dashboard to measure employee completion rates to ensure your training knowledge is being retained.

Remote Controls Setup

1. Create Remote Variables

To start using Remote Variables in Unity, you'll need create Remote Variables on the Dashboard. See Dashboard Remote Controls for details.

2. Remote Controls in Unity

In the Unity Editor, add the RemoteControls component to the Cognitive3D_Manager GameObject in your scene.

Remote Controls component

The component will try to identify the ParticipantId to be used with Sticky A/B Tests. This option on the Dashboard will consistently return variants to the same user. If this ParticipantId is not available, it will fall back and use the DeviceId instead. You can adjust the following settings:

  • Fetch Variables Automatically - When enabled, this component will return Remote Variables from our Dashboard when the Session starts. If Use Participant Id is true, it may wait for the ParticipantId to be set if it is not already.

  • Use Participant Id - When enabled, the ParticipantId will be used to identify the Session to fetch Remote Variables. If disabled, the DeviceId will be used instead.

  • Wait for Participant Id Timeout - This field defines the amount of time the Cognitive3D SDK will wait for the ParticipantId to be set if it is not already available at the start of the session. If the ParticipantId is not set within this time, the DeviceId will be used to identify the Session.

API Reference

Fetching Remote Variables

To manually fetch the Remote Variables from the Dashboard (instead of using the Automatic toggle on the component), you can call the FetchVariables function.

// A function you call from your app
public void YourDelayedStartupFunction()
{
    // Fetching Remote variables using device ID
    Cognitive3D.Components.RemoteControls.FetchVariables();

    // Or fetching Remote variables using participant ID
    Cognitive3D.Cognitive3D_Manager.SetParticipantId("participant1");
    Cognitive3D.Components.RemoteControls.FetchVariables(Cognitive3D.Cognitive3D_Manager.ParticipantId);
}

Using Remote Variable Value

To use a Remote Variable, first ensure that you've fetched the Variables from the Dashboard (either automatically from the component settings, or the function call described above). You can access the Variable's value using the following code:

// A function you call from your app
public void YourFunction()
{
    // Retrieve an remote variable by its name with a default value
    // For a string-type remote variable
    Cognitive3D.RemoteControlManager.GetValue<string>("RemoteVariableName", "defaultValue");

    // For an integer-type remote variable
    Cognitive3D.RemoteControlManager.GetValue<int>("RemoteVariableName", 0);

    // For a boolean-type remote variable
    Cognitive3D.RemoteControlManager.GetValue<bool>("RemoteVariableName", false);
}

You can also use the OnRemoteControlsAvailable event to wait until the Remote Variables are available:

void Start()
{
    // If Remote Variables are already available
    if (Cognitive3D.RemoteControlManager.HasFetchedVariables)
    {
        OnRemoteControlsAvailable();
    }
    else
    {
        // Subscribe to the OnRemoteControlsAvailable event
        Cognitive3D.RemoteControlManager.OnRemoteControlsAvailable += OnRemoteControlsAvailable;
    }    
}

void OnRemoteControlsAvailable()
{
    Cognitive3D.RemoteControlManager.OnRemoteControlsAvailable -= OnRemoteControlsAvailable;
    // Retrieve the value of a remote variable (example for an int type)
    var value = Cognitive3D.RemoteControlManager.GetValue<int>("RemoteVariableName", 0);

    Debug.Log($"Remote variable value is {value}");
}

intercom If you have a question or any feedback about our documentation please use the Intercom button (purple circle) in the lower right corner of any web page.