Implementation Example

Blueprint Implementation Example

1. Create an Opt-In UI Widget:

  • Design a widget that includes the necessary buttons and text.

2. Trigger Opt-In Logic:

  • Use a Branch node in Event BeginPlay to check the OptInStatus.

  • If the player has opted in, call the StartRecording function.

  • If not, display the opt-in widget.

Event BeginPlay
    -> Branch (Condition: Check if Player Opted In using a Bool variable "OptInStatus")
        -> True: PlayAI Start Recording (Call StartRecording function on PlayAI Component)
        -> False: Display Opt-In Widget (Show UI with "Opt In", "Learn More", "Ignore" options)

"Opt In" Button Clicked
    -> Set Bool "OptInStatus" to True
    -> Share Player Info (Blueprint or C++ function to share information)
    -> PlayAI Start Recording (Call StartRecording function on PlayAI Component)
    -> Remove Opt-In Widget (Hide UI)
    

C++ Implementation Example


void AYourGameMode::BeginPlay()
{
    Super::BeginPlay();

    if (OptInStatus)
    {
        StartRecording();
    }
    else
    {
        DisplayOptInWidget();
    }
}

void AYourGameMode::OptIn()
{
    OptInStatus = true;

    // Share player information here
    SharePlayerInfo();

    StartRecording();
}

void AYourGameMode::SharePlayerInfo()
{
    // Code to share player information
}

void AYourGameMode::StartRecording()
{
    if (PlayAIManager)
    {
        PlayAIManager->StartRecording();
    }
}

void AYourGameMode::DisplayOptInWidget()
{
    // Logic to display the opt-in UI widget
}

Explanation of the Code:

  • BeginPlay: On game start, checks the OptInStatus. If the player has opted in, recording starts automatically.

  • OptIn: This method sets the OptInStatus to true, shares the player's information, and starts recording.

  • SharePlayerInfo: Handles the logic for sharing player information upon opt-in.

Opt-In Flow in Unreal Engine:

  • Initial Display: The opt-in prompt appears at the beginning of the game if the player hasn't previously opted in.

  • Player Decision:

    • Opt-In: The player’s decision is saved, their information is shared, and recording begins.

    • Ignore: The prompt is dismissed without recording, and the player is re-prompted later.

    • Learn More: Provides additional information about opting in.

Last updated