Skip to main content

Use UGC for player presets

Last updated on October 24, 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.

This article walks you through how to use the UGC service to store player-generated content, display them within the game client, and use them according to your game use case.

Prerequisites

You will need access to:

  • The AccelByte Gaming Services (AGS) Admin Portal
  • The AGS Unreal or Unity SDK
  • The AGS UGC API documentation for reference.

Create channel to store player content

UGC service manages player content based on channels. A channel is a generic entity that is used to categorize players' content. You can use channels 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 SDK

FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();

FString ChannelName = "YourChannelName";

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

Get the list of the player channel using the 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 succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetChannels fails
}), Limit, Offset, ChannelName);

Store 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 subtype. 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

Get a Pre-Signed URL using the 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 succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if CreateV2Content fails
}));

Upload the Player content file using the SDK

note

You'll need a pre-signed URL for this function. See Get a pre-signed URL using the Client SDK.

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 succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if UploadTo fails
}));

Add screenshots to 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 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 succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if UploadV2ScreenshotContent fails
}));

Upload the screenshot using the SDK

To upload screenshot for a specific player content to cloud storage, use this function:

note

You'll need a pre-signed URL for this function. See Get a pre-signed URL using the Client SDK.

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 succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if UploadTo fails
}));

Display player content by share code

When a player creates a player content, UGC service will generate a unique share code for it. The player can share the share code with other players to show off their creation or invite them to try it out. Other players can use the share code 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 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 succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetV2ContentByShareCode fails
}));

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 SDK

To update the player content metadata, use this function:

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 succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if ModifyV2Content fails
}));

Request a Pre-Signed URL using the SDK

To get a pre-signed URL that you can use to upload your updated player content to cloud storage, use this function:

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 succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GenerateUploadContentURLV2 fails
}));

Upload the updated Player content file using the SDK

note

You'll need a pre-signed URL for this function. See Get a pre-signed URL using the Client SDK.

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 succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if UploadTo fails
}));

Update the Player content file location using the 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 succeeds
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if UpdateContentFileLocationV2 fails
}));

Delete player content

Delete player content using the Client SDK

FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();

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

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