By using AWS re:Post, you agree to the AWS re:Post Terms of Use

How to start game session before players join

0

Hello, I am using Unreal Engine. I need to create game sessions automatically after game server process is ready. The reason is that when multiple players send join request at the same time, there is no available game session. So they each create their own game sessions. I want them to be in the same game session. How do I create game sessions automatically after game server is ready?

asked 15 days ago16 views
1 Answer
0

To create game sessions automatically after your game server process is ready in Unreal Engine using Amazon GameLift, you can follow these steps:

  1. First, ensure that your game server is properly initialized and ready to host game sessions. This is typically done using the ProcessReady() function from the GameLift SDK.

  2. Once your server is ready, you can use the ActivateGameSession() function within your onStartGameSession delegate. This delegate is called by GameLift when a new game session is created.

  3. Here's an example of how you might implement this in your Unreal Engine project:

auto onGameSession = [=](Aws::GameLift::Server::Model::GameSession gameSession)
{
    FString gameSessionId = FString(gameSession.GetGameSessionId());
    UE_LOG(GameServerLog, Log, TEXT("GameSession Initializing: %s"), *gameSessionId);
    gameLiftSdkModule->ActivateGameSession();
};
  1. By activating the game session immediately when it's created, you ensure that the session is ready to accept players before any join requests come in.

  2. To create the initial game session, you can use the CreateGameSession API call from your game client or a separate service. This will trigger the creation of a game session on an available server.

  3. Once the game session is created and activated, players can join using the CreatePlayerSession or CreatePlayerSessions API calls.

By following this approach, you can ensure that a game session is always available when players attempt to join, preventing the issue of multiple players creating separate sessions simultaneously. This method allows you to have more control over when and how game sessions are created, ensuring that players are grouped into the same session as intended.
Sources
Amazon GameLift server SDK 5.x for Unreal Engine: Actions - Amazon GameLift
CreateGameSession - Amazon GameLift
CreatePlayerSessions - Amazon GameLift

profile picture
answered 15 days ago
  • What services can i use to call CreateGameSession API?

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions