Skip to main content
Version: 5.11.6

CreateCharacter

public BackendReturnObject CreateCharacter(string nickname);

Parameters

ValueTypeDescription
nicknamestringNickname of the character to create

Description

Create a new character in the user's account. Nicknames cannot be used in duplicates.
You can create up to 20 characters.

  • When a character is successfully created, inDate and uuid, the return values required for character selection(SelectCharacter), are displayed. You can use these values to immediately select a character and log in.

Example

Synchronous


BackendReturnObject bro = Backend.MultiCharacter.Character.CreateCharacter("Nickname");
if(bro.IsSuccess()) {
Debug.Log("Successfully created the character.");
Debug.Log("gamerInDate: " + bro.GetReturnValuetoJSON()["gamerInDate"].ToString());
Debug.Log("uuid: " + bro.GetReturnValuetoJSON()["uuid"].ToString());
}

Asynchronous

BackendReturnObject bro = Backend.MultiCharacter.Character.CreateCharacter("Nickname", callback => {
if(callback.IsSuccess()) {
Debug.Log("Successfully created the character.");
Debug.Log("gamerInDate: " + bro.GetReturnValuetoJSON()["gamerInDate"].ToString());
Debug.Log("uuid: " + bro.GetReturnValuetoJSON()["uuid"].ToString());
}
});

SendQueue

SendQueue.Enqueue(Backend.MultiCharacter.Character.CreateCharacter, "Nickname", callback => {
if(callback.IsSuccess()) {
Debug.Log("Successfully created the character.");
Debug.Log("gamerInDate: " + bro.GetReturnValuetoJSON()["gamerInDate"].ToString());
Debug.Log("uuid: " + bro.GetReturnValuetoJSON()["uuid"].ToString());
}
});

ReturnCase

Success cases

When a character is created successfully
statusCode : 201

returnValue : {"gamerInDate":"2023-06-19T07:54:08.420Z","uuid":"7869e640-0e76-11ee-866a-61533cb2837b"}

Error cases

When there are over 20 characters
statusCode : 403
errorCode : ForbiddenException

When the nickname already exists
statusCode : 409
errorCode : DuplicatedParameterException

SampleCode

The following code is a logic that selects and saves the default customization values after character creation.

Backend.MultiCharacter.Account.CreateAccount("user12", "user12");
var bro = Backend.MultiCharacter.Character.CreateCharacter("character 2");
if(bro.IsSuccess() == false) {
Debug.LogError("Failed to create the character.");
return;
}
LitJson.JsonData userData = bro.GetReturnValuetoJSON();
string uuid = userData["uuid"].ToString();
string inDate = userData["gamerInDate"].ToString();
bro = Backend.MultiCharacter.Character.SelectCharacter(uuid, inDate);

if(bro.IsSuccess() == false) {
Debug.LogError("Failed to select the character.");
return;
}
// Character customization
Param param = new Param();
param.Add("head", "default-1");
param.Add("clothes", "default-1");
param.Add("shoes", "default-2");
param.Add("class", "warrior");
param.Add("weapon", "BattleAXE");
bro = Backend.GameData.Insert("USER_DATA", param);
if(bro.IsSuccess()) {
Debug.Log("The character has been successfully reset.");
}
// If returning to the character screen
Backend.BMember.Logout();
//SceneManager.LoadScene("characterScene");
// If starting the game
//SceneManager.LoadScene("ingameScene");