Skip to main content

Using UGC for Player Presets

Last updated on May 13, 2024

Overview

User Generated Content (UGC) is a service that manages in-game content that has been created by your players. UGC can be a powerful way to increase engagement, retention, and loyalty among your customers, as well as to attract new ones. There are different forms of UGC, depending on the game. The opportunities are endless, but some of these items include: customizing the game character, customizing the color of a vehicle, new aspects of a weapon, creating custom maps, and so much more.

There are a lot of games that implement deep customization to their player content. With a content customization, It can increase the player's immersion and engagement with the game world, as they can create content that reflects their personality, preferences, and style. Also, it can encourage social interaction and community building among players, especially if they can make a preset out of their content and share it with others. By allowing players to showcase their creativity and identity through their content, developers can create a loyal fan base and generate positive word-of-mouth for their game.

In this guide, you will learn how to utilize the UGC service to store the player's contents, display it within the game client, and use it according to your game use case.

Goals

The goals of this section are to:

  • Provide an understanding and overview of UGC for player content
  • Provide an understanding on how to store player content in UGC
  • Provide an understanding on how to add screenshots to the player content
  • Provide an understanding on how to display the player content
  • Provide an understanding on how to display the player content by the share code
  • Provide an understanding on how to modify the player content
  • Provide an understanding on how to delete the player content
  • Explain how to utilize the AccelByte SDK to manage UGC player contents.

Prerequisites

You will need access to:

  • The AccelByte Admin Portal
  • The AccelByte Unreal or Unity SDK
  • The AccelByte UGC API documentation for further reference

Create Channel to store the Player Content

UGC service manages Players content based on channel. Channel is a generic entity that is used to categorize Players' content. We can use the channel to group contents by region, language, build version, patch, content category, or any other cases that are needed for the game scenario. It can be hardcoded or the game could let the player manage their own channel.

Create a channel using the Client SDK

You can use this function to create a channel.

FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();

FString ChannelName = "YourChannelName";

ApiClient->UGC.CreateChannel(ChannelName, THandler<FAccelByteModelsUGCChannelResponse>::CreateLambda([](const FAccelByteModelsUGCChannelResponse& Result)
{
// Do something if CreateV2Channel is successful
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if CreateV2Channel has an error
}));

Get the list of the player channel using the Client SDK

You can use this function to list of the player channel.

FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();

FString UserId = "YourUserId";
int32 Limit = 1000;
int32 Offset = 0;
FString ChannelName = "YourChannelName";

ApiClient->UGC.GetChannels(UserId, THandler<FAccelByteModelsUGCChannelsPagingResponse>::CreateLambda([](const FAccelByteModelsUGCChannelsPagingResponse& Result)
{
// Do something if GetChannels is successful
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetChannels has an error
}), Limit, Offset, ChannelName);

Storing Player Content In UGC

If you want to save your Player content in UGC service as preset, you need to create a file that contains all the customization options you have applied to your player content. This file will store the information about your Player content.

To create Player content in UGC service, you need to complete two steps. First, you need to request a pre-signed URL from the service that will allow you to upload your file. In this step, you can also specify the basic metadata for the Player content, such as name, tags, type, and sub-type. Second, you need to use the pre-signed URL to upload your file to the service.

Get a Pre-Signed URL using the Client SDK

You can use this function to set the Player content metadata and get a pre-signed URL that you can use to upload your Player content to cloud storage.

FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();

FString ChannelId = "YourChannelId";
FAccelByteModelsCreateUGCRequestV2 UGCRequest = {};
UGCRequest.ContentType = "PNG";
UGCRequest.FileExtension = "PNG";
UGCRequest.Name = "UGC Integration UE4";
UGCRequest.Type = "UGC Type";
UGCRequest.SubType = "UGC SubType";
UGCRequest.Tags = { "UGC Tag1", "UGC Tag2"};

ApiClient->UGC.CreateV2Content(ChannelId, UGCRequest, THandler<FAccelByteModelsUGCCreateUGCResponseV2>::CreateLambda([](const FAccelByteModelsUGCCreateUGCResponseV2& Result)
{
// Do something if CreateV2Content is successful
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if CreateV2Content has an error
}));

Upload the Player content file using the Client SDK

To upload the Player content to cloud storage, use the following function. You’ll need the pre-signed URL you retrieved in the previous step.

FString Url = "PayloadUGCUrlToUpload";
TArray<uint8> DataUpload = { 106, 35, 171, 106, 138, 197, 77, 94, 182, 18, 99, 9, 245, 110, 45, 197, 22, 35};

FAccelByteNetUtilities::UploadTo(Url, DataUpload, FHttpRequestProgressDelegate::CreateLambda([](const FHttpRequestPtr& Request, int32 BytesSent, int32 BytesReceived)
{
// Do something if UploadTo still in progress successful
}),FVoidHandler::CreateLambda([]()
{
// Do something if UploadTo is successful
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if UploadTo has an error
}));


Add Screenshots To The Player Content

One way to make your Player content file more attractive and informative is to add a screenshot that shows how it looks in the game. A screenshot can capture the visual effects and details that you have created with your preset file.

Get a Pre-Signed URL for uploading the screenshot using the Client SDK

You can use this function to get a pre-signed URL that you can use to upload your screenshot for a specific Player content.

FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();

FString ContentId = "YourContentId";
FString UserId = "UserId";

FAccelByteModelsUGCUploadScreenshotV2 Screenshot;
Screenshot.Description = "Screenshot Test Description";
Screenshot.ContentType = "png";
Screenshot.FileExtension = "png";

FAccelByteModelsUGCUploadScreenshotsRequestV2 ScreenshotsRequest = {};
ScreenshotsRequest.Screenshots = { Screenshot };

ApiClient->UGC.UploadV2ScreenshotContent(ContentId, ScreenshotsRequest, THandler<FAccelByteModelsUGCUpdateContentScreenshotResponse>::CreateLambda([](const FAccelByteModelsUGCUpdateContentScreenshotResponse& Result)
{
// Do something if UploadV2ScreenshotContent is successful
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if UploadV2ScreenshotContent has an error
}));

Upload the screenshot using the Client SDK

To upload screenshot for a specific Player content to cloud storage, use the following function. You’ll need the pre-signed URL you retrieved in the previous step.

FString Url = "PayloadScreenshotUrlToUpload";
TArray<uint8> DataUpload = { 35, 171, 106, 138, 197, 77, 94, 182, 18, 99, 9, 245, 110, 45, 197, 35};

FAccelByteNetUtilities::UploadTo(Url, DataUpload, FHttpRequestProgressDelegate::CreateLambda([](const FHttpRequestPtr& Request, int32 BytesSent, int32 BytesReceived)
{
// Do something if UploadTo still in progress successful
}),FVoidHandler::CreateLambda([]()
{
// Do something if UploadTo is successful
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if UploadTo has an error
}));


Display The Player Content By The Share Code

When a player creates a Player content, UGC service will generate a unique sharecode for it. The player can share the sharecode with other players to show off their creation or invite them to try it out. Other players can use the sharecode to access the details of the preset. They can also apply the preset to their own game or modify it as they wish.

Displaying the Player content by the share code using Client SDK

This example below shows you how to retrieve the Player content using the sharecode.

FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();

FString ShareCode = "YourUGCShareCode";

ApiClient->UGC.GetV2ContentByShareCode(ShareCode, THandler<FAccelByteModelsUGCContentResponseV2>::CreateLambda([](const FAccelByteModelsUGCContentResponseV2& Result)
{
// Do something if GetV2ContentByShareCode is successful
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetV2ContentByShareCode has an error
}));

Modify The Player Content

When modifying the Player content, player could update only the Player content metadata, or the preset file.

To modify the preset file in UGC service, you need to complete three steps. First, you need to request a pre-signed URL from the service that will allow you to upload your new file. Second, you need to use the pre-signed URL to upload your file to the service. Third, you need to commit the changes by updating the new file location.

Update the Player content metadata using the Client SDK

You can use this function to update the Player content metadata.

FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();

FString ChannelId = "YourChannelId";
FString ContentId = "YourContentId";

FAccelByteModelsModifyUGCRequestV2 ModifyRequest = {};
ModifyRequest.Name = "Updated UGC Integration UE4";
ModifyRequest.Type = "Updated UGC Type";
ModifyRequest.SubType = "Updated UGC SubType";
ModifyRequest.Tags = { "Updated UGC Tag1", "Updated UGC Tag2"};

ApiClient->UGC.ModifyV2Content(ChannelId, ContentId, ModifyRequest, THandler<FAccelByteModelsUGCModifyUGCResponseV2>::CreateLambda([](const FAccelByteModelsUGCModifyUGCResponseV2& Result)
{
// Do something if ModifyV2Content is successful
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if ModifyV2Content has an error
}));

Request a Pre-Signed URL using the Client SDK

You can use this function to get a pre-signed URL that you can use to upload your updated Player content to cloud storage.

FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();

FString ChannelId = "YourChannelId";
FString ContentId = "YourContentId";

FAccelByteModelsUploadContentURLRequestV2 UploadRequest = {};
UploadRequest.ContentType = "PNG";
UploadRequest.FileExtension = "PNG";

ApiClient->UGC.GenerateUploadContentURLV2(ChannelId, ContentId, UploadRequest, THandler<FAccelByteModelsUGCUploadContentURLResponseV2>::CreateLambda([](const FAccelByteModelsUGCUploadContentURLResponseV2& Result)
{
// Do something if GenerateUploadContentURLV2 is successful
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GenerateUploadContentURLV2 has an error
}));

Upload the updated Player content file using the Client SDK

To upload the updated Player content file to cloud storage, use the following function. You’ll need the pre-signed URL you retrieved in the previous step.

FString Url = "PayloadUpdatedUGCUrlToUpload";
TArray<uint8> DataUpload = { 106, 35, 171, 106, 138, 197, 94, 182, 18, 99, 9, 245, 110, 45, 197, 35};

FAccelByteNetUtilities::UploadTo(Url, DataUpload, FHttpRequestProgressDelegate::CreateLambda([](const FHttpRequestPtr& Request, int32 BytesSent, int32 BytesReceived)
{
// Do something if UploadTo still in progress successful
}),FVoidHandler::CreateLambda([]()
{
// Do something if UploadTo is successful
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if UploadTo has an error
}));

Update the Player content file location using the Client SDK

Once the Player content file is uploaded, commit the changes to make sure the new file location is updated by using the following function:

FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();

FString ChannelId = "YourChannelId";
FString ContentId = "YourContentId";
FString FileExtension = "PNG";
FString S3Key = "YourContentS3Key";

ApiClient->UGC.UpdateContentFileLocationV2(ChannelId, ContentId, FileExtension, S3Key, THandler<FAccelByteModelsUGCUpdateContentFileLocationResponseV2>::CreateLambda([](const FAccelByteModelsUGCUpdateContentFileLocationResponseV2& Response)
{
// Do something if UpdateContentFileLocationV2 is successful
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if UpdateContentFileLocationV2 has an error
}));

Delete The Player Content

Delete the Player content using the Client SDK

You can use this function to delete the Player content.

FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();

FString ChannelId = "YourChannelId";
FString ContentId = "YourContentId";

ApiClient->UGC.DeleteV2Content(ChannelId, ContentId, FVoidHandler::CreateLambda([]()
{
// Do something if DeleteV2Content is successful
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if DeleteV2Content has an error
}));