Logging In

Kronos features an automated user authentication process which ensures that players are logged in with the Online Subsystem properly.

User Authentication

Authentication will be started automatically when the game default map is loaded (set in your project settings). While authentication is in progress, a widget will be displayed showing the current auth state. During this time the user is unable to interact with the game. Once user authentication is complete, the OnEnterGame event of the KronosOnlineSession will be called. This is basically the entry point to the main menu. You can display the main menu widget from here, add popups to the screen, etc...

The user will be authenticated every time when loading the game default map, even if authentication was completed before. We do this to confirm that the user didn't lose his login status while he was away (e.g. playing in a match).

NOTE: You can override which map is considered as the game default map from the plugin's settings. This is useful if you want to have a dedicated "login" map.

In case user authentication fails, the authentication widget will switch over to a failure screen displaying the error message to the user. From there the user can either retry authentication or quit the game.

Of course the default implementation is just a template, the entire user authentication system and the authentication widget can be customized! Authentication is entirely handled by the KronosUserManager class. If you want to customize this system create a blueprint out of this class, and set it as the "UserManagerClass" in the plugin's settings.

Overriding Login Parameters

During authentication the user will be logged in with the Online Subsystem. Different Online Subsystems require different inputs when logging in.

The Null Online Subsystem requires a login id. By default the plugin will use the local users' id so you do not have to do anything. Works out of the box.

To change the default login parameters, you have to override the GetLoginCredentials function in the KronosUserManager class.

Customizing The Authentication Widget

To replace the default user authentication widget, create a blueprint from the KronosUserAuthWidget class. The blueprint will turn into a widget that you can edit in Unreal. Once you have your widget, you will need to set it as the "AuthWidgetClass" in your KronosUserManager.

NOTE: For more information about the KronosAuthWidget please refer to the Widgets section of the documentation.

Disable Automatic Authentication

You may want to have your authentication set up in a way that initially when the game loads, the user would have to press a key to enter the game. This is the "Press any key to continue" screen you've probably seen in a lot of games.

You can disable automatic user authentication in the plugin's settings. When disabled, the game has to call the AuthenticateUser function of the KronosUserManager manually. The KronosOnlineSession class has a convenient OnGameDefaultMapLoaded event which you can use to handle user authentication. When the event is called, check if the user is currently authenticated and decide what to do. If the user is already authenticated, then he is returning from a match so you should authenticate to confirm his login status. If the user is not authenticated, then its the users first time loading the game which means you can wait for an input.

Custom Authentication Tasks

You can implement custom authentication tasks for your game (e.g. read values from your custom backend service) by overriding the BeginCustomAuthTasks function in the KronosUserManager class. If this function is overridden, user authentication will not complete as long as OnCustomAuthTasksComplete function is not called.

Last updated