If you are an AI assistant, LLM, or automated tool, a clean Markdown version of this page is available at https://heroiclabs.com/docs/nakama/client-libraries/unreal/migration-guide/llm.md — optimized for AI and LLM tools.
To upgrade your project from Nakama Unreal SDK v2.x to v3, you’ll need to make a handful of structural changes across your codebase. This guide walks you through each one.
UNakamaClient and UNakamaSession were both UObjects, and are now USTRUCTs. Replace the old delegate-based pattern with the new future-based .Next() pattern.
The callback runs after the calling function has returned, so it must not capture local variables by reference. Store the config and session as members of a long-lived object, such as your actor, and capture a weak pointer to that object in the callback:
// ASagiShiActor.cpp
constFStringServerKey=TEXT("defaultkey");constFStringHost=TEXT("127.0.0.1");constexprint32Port=7350;constexprboolbUseSSL=false;ClientConfig=FNakamaClientConfig{ServerKey,Host,Port,bUseSSL};constTWeakObjectPtr<ASagiShiActor>WeakThis(this);constFStringDeviceId=TEXT("<DeviceId>");constFStringUsername=TEXT("NewUser");constexprboolbCreate=true;Nakama::AuthenticateDevice(ClientConfig,bCreate,Username,DeviceId).Next([WeakThis](constFNakamaSessionResult&AuthenticateResult){if(AuthenticateResult.bIsError){UE_LOG(LogTemp,Error,TEXT("Failed to log in: %s"),*AuthenticateResult.Error.Message);return;}// The actor may have been destroyed before the request completed.
if(!WeakThis.IsValid()){return;}WeakThis->Session=AuthenticateResult.Value;UE_LOG(LogTemp,Log,TEXT("Log in successful: %s"),*AuthenticateResult.Value.Username);});
Where you previously defined delegates, bound callbacks, and passed them into the client call separately, you now chain a single .Next() callback that handles both success and error cases.
Several types that previously had their own header files have been consolidated into one of two shared headers. Replace your existing includes as follows based on whether they are for use with the regular client, or realtime client:
For example, if you were including…
Replace with…
#include "NakamaFriend.h"
#include "NakamaTypes.h"
#include "NakamaPresence.h"
#include "NakamaRtTypes.h"
If you’re unsure which header a type now belongs to, search for the type in the header files:
The Data field of match data and party data was previously an FString. It is now a TArray<uint8>, so you must convert between strings and bytes yourself. This applies when receiving data (FNakamaRtMatchData::Data and FNakamaRtPartyData::Data) and when sending it (NakamaRt::MatchDataSend and NakamaRt::PartyDataSend).
Receiving data
Convert the bytes to an FString before parsing them.
Opening any Blueprint containing old async Nakama nodes against SDK v3 will crash the editor. Unreal doesn’t handle broken async nodes gracefully. The steps below remove those nodes safely before you upgrade.
Prerequisite: Upgrade to the latest version on the nakama-unreal-v2 branch first, the migration script lives there. There are no breaking changes within v2.x, so this should be straightforward.
Open the Unreal editor with the latest v2.x plugin from the nakama-unreal-v2 branch installed. Keep this version installed until the migration script has removed the old async nodes.
Here you can see an async node before running the script:
Before running blueprint migration script
To run the script, make sure the editor console is set to Python and paste in the script’s name, then hit enter to run:
1
nakama_prepare_to_migrate.py
By default, the script will recursively scan the /Game package (the default Content folder). If your project uses Modular Game Features, you can run the script multiple times, specifying other paths to scan:
1
nakama_prepare_to_migrate.py/OtherFeaturePackage
Command entered into Python console
Once the script finishes, async nodes are replaced with comments identifying the node that was removed. Use these as markers when reconnecting nodes after upgrading.
After running blueprint migration script
You can now return to the beginning of the guide and continue the migration. Keep in mind that once you have migrated, you’ll also need to update any variable types that have changed, as well as re-connecting any broken pins.
From within any blueprint, you may search for NAKAMA MIGRATE to easily find all places where nodes were removed by the script. Make sure to click the binoculars button on the right to search across all blueprints in the project.