Improbable Icon

UnityGDK feature request: passing custom data in the lifecycle



When, using the GDK, I create a player / start the game I would like to send custom data along for authentication purposes. In the SDK you created your own PlayerCreator but with the new Lifecycle component in the GDK this is done for you.

What I would love is if you could pass a dictionary with custom data so that you can retrieve player data during entity instantiation and pre-populate the components of the player with information from your backend.


Hey @draconigra,

Thanks for your thoughts and feedback on this. I’ll pass this on to our dev team :slight_smile:



Hey @draconigra, unfortunately at the moment this is unsupported. The PlayerLifecycle module is fairly raw and needs a bit of TLC in the future.

What sort of player data do you want to retrieve from the backend? Could this be done server side given the Worker ID of the client that sent the CreatePlayer command?

As a workaround, you can always copy the module as source into your project and modify as required if you are blocked by this.


What is needed is that upon calling ‘connect’ in the client I’d want to pass the player identifier as received by my backend (GameSparks in this instance) and ideally a secret or CRC hash with which I can verify the validity of the player id in question.

Then in the creation of the Player entity (or at least in the OnConnected on the worker side) I’d want to receive that player id and secret, and perform a check and load the user data. In this part I should be able to reject the connection if the passed player id and secret do not verify.

My request for custom variables / a dictionary is because I can understand that other people may have different fields that they need for their authentication / player recognition scheme.

Currently, you cannot persist data of a player because you cannot identify a player without an additional command, but first accepting the connection and then receiving a command to load the state may introduce different issues. To do this on connect makes it easier to handle


Forgot to update this issue as I had also mentioned this on Discord. I have chosen to (temporarily) fork the GDK and make a couple of changes to the lifecycle component to add support for this:

I hope it is possible to integrate these changes, or those similar to these, as I prefer not to support a forked version for too long as the GDK changes frequently and significantly enough that I would need to update the fork and resolve merge conflicts :slight_smile:


I’d also like to see these changes or simular pushed, for the exact same limitation @draconigra desribes. Cheers for sharing the fork @dracongra, if its of any use, I use the following cloudCode in GS to validate on remote workers the users unique auth token as sent in the connection response from GS:

var otherPlayerID = Spark.getData().PLAYER_ID;
var player = Spark.loadPlayer(otherPlayerID);
var authToken = Spark.getData().AUTH_TOKEN;

var playerId = checkPlayerHasAuthTicket();

function checkPlayerHasAuthTicket(){
var playerFound = Spark.systemCollection("player").findOne({ "_id" : { "$oid" :otherPlayerID}},{"authTokens" : 1});

if(playerFound === null   ){
    return false;

 for (index = 0; index < playerFound.authTokens.length; ++index) 
     var str = playerFound.authTokens[index];
    str = str.substring(0, str.length - 5);

    if(str == authToken){
        return true;
return false;

var response = playerId;

Spark.setScriptData("AuthResponse", response);