- 最新
- 最多得票
- 最多評論
I am currently working on Unreal Engine 5.1.1 game project. I have integrated GameLiftServerSDK in to our game as we want to use dedicated servers hosted on AWS GameLift. I have downloaded latest version of Unreal - GameLift plugin SDK (5.0.0) and fallowed latest tutorial for integration in to UE.
For testing purpose I have created simple Unreal project from Third Person Template with GameLiftServerSDK plugin. I have added code from latest integration guide: https://docs.aws.amazon.com/gamelift/latest/developerguide/integration-engines-setup-unreal.html to the GameMode class of the test project.
I have access to Amazon GameLift Console where I have setup Fleet (type Anywhere) and I have configured my desktop workstation as compute in custom location in that fleet. Before running dedicated server package, I run aws gamelift get-compute-auth-token command, and use token as parameter in executable shortcut.
Every time I try to run dedicated server (with all preparations) I get crash
EXCEPTION_ACCESS_VIOLATION <CallStack>ProjectServer!OnHealthCheckInternal() ...\Plugins\GameLiftServerSDK\Source\GameLiftServerSDK\Private\GameLiftServerSDK.cpp:245]
Hi,
Amazon GameLift has added support for Unreal Engine 5, please check out the latest developer guide for instruction to integrate: https://docs.aws.amazon.com/gamelift/latest/developerguide/integration-engines-setup-unreal.html
Related: https://aws.amazon.com/about-aws/whats-new/2023/04/amazon-gamelift-unreal-engine-5/
I have found solution. Add private member variables:
FGameLiftServerSDKModule* GameLiftSdkModule;
FProcessParameters GameLiftProcessParams;
FServerParameters serverParameters;
To your YourProjectGameMode class. Do not use lambda functions for delegates OnHealthCheck, OnTerminate and onGameSession but create regular functions and bind them to delegates.
UYourProjectGameMode::UYourProjectGameMode() {
...
GameLiftSdkModule = nullptr;
GameLiftProcessParams.OnStartGameSession.BindUObject(this, &UYourProjectGameMode::OnGameSessionActivated);
GameLiftProcessParams.OnUpdateGameSession.BindUObject(this, &UYourProjectGameMode::OnUpdateGameSessionReceived);
GameLiftProcessParams.OnHealthCheck.BindUObject(this, &UYourProjectGameMode::OnHealthCheckReceived);
GameLiftProcessParams.OnTerminate.BindUObject(this, &UYourProjectGameMode::OnTerminateServerProcess);
...
}
void UYourProjectGameMode::InitGameLift()
{
UE_LOG(LogTemp, Log, TEXT("Initializing the GameLift Server"));
GameLiftSdkModule = &FModuleManager::LoadModuleChecked<FGameLiftServerSDKModule>(FName("GameLiftServerSDK"));
...
}
void UYourProjectGameMode::OnGameSessionActivated(Aws::GameLift::Server::Model::GameSession ActivatedSession)
{
// When a game session is created, GameLift sends an activation request to the game server and passes along the game session object
// containing game properties and other settings.
// Here is where a game server should take action based on the game session object.
// Once the game server is ready to receive incoming player connections, it should invoke GameLiftServerAPI.ActivateGameSession()
CurrentGameSessionId = FString(ActivatedSession.GetGameSessionId());
UE_LOG(LogTemp, Log, TEXT("GameSession Initializing: %s"), *CurrentGameSessionId);
if (GameLiftSdkModule != nullptr)
{
GameLiftSdkModule->ActivateGameSession();
}
}
void UYourProjectGameMode::OnUpdateGameSessionReceived(Aws::GameLift::Server::Model::UpdateGameSession UpdatedSession)
{
FString gameSessionId = FString(UpdatedSession.GetGameSession().GetGameSessionId());
UE_LOG(LogTemp, Log, TEXT("GameSession Updated: %s"), *gameSessionId);
//GameLiftSdkModule->ActivateGameSession();
}
bool UYourProjectGameMode::OnHealthCheckReceived()
{
// This is the HealthCheck callback. GameLift will invoke this callback every 60 seconds or so.
// Here, a game server might want to check the health of dependencies and such. Simply return true if healthy, false otherwise.
// The game server has 60 seconds to respond with its health status. GameLift will default to 'false' if the game server doesn't respond in time.
// In this case, we're always healthy!
UE_LOG(LogTemp, Log, TEXT("Performing Health Check"));
return true;
}
void UYourProjectGameMode::OnTerminateServerProcess()
{
// OnProcessTerminate callback. GameLift will invoke this callback before shutting down an instance hosting this game server.
// It gives this game server a chance to save its state, communicate with services, etc., before being shut down.
// In this case, we simply tell GameLift we are indeed going to shutdown.
UE_LOG(LogTemp, Log, TEXT("Game Server Process is terminating"));
if (GameLiftSdkModule != nullptr)
{
GameLiftSdkModule->ProcessEnding();
}
}
相關內容
- 已提問 1 年前
- AWS 官方已更新 1 年前
I have the exact same problem. Were you able to solve it?