[ARTICLE] Explanation on how I used GameSparks Matchmaking and AWS Dedicated Server

I just wrote a high level explanation of how I did GameSparks matchmaking and starting of new dedicated servers. Hope it helps

More info: GameSparks Matchmaking and starting dedicated servers on AWS | Unreal X-Editor

Added to the to-watch/read list :slight_smile:

Hi ryanJon2040,
from GameSparks Customer success team here. Thank you for taking the time to write and document your interactions with our platform and team. Just wanted to extend our thanks.
If you ever need any further help, please don’t hesitate to contact us through our support ticket service or communiy forums.

Best Regards, .

Ryan,
Any chance you may be able to do a video tutorial on this? I read your blog but not really sure where to start?

Hi @fender21,

Even though I would like to make a video tutorial, unfortunately I don’t have enough time as I am busy with my office projects. But please feel free to ask your questions here and I will definitely help you out. :slight_smile:

This is a great read and it came just in time when I needed it. Thanks!

Happy to hear it helps :). If you need further help please do message here. I am more than happy to help if anyone needs assist. :slight_smile:

Probably a bit too much to ask, but it would be very helpful if you could upload a sample project it would be awesome :wink:

Very nice, I checked out the video. Glad to see things are working for you.

Why do you need Amazon server, i thought Gamesparks offers a complete solution?

And how do you store the Secret ID, in the client or only on server?

Related https://bitbucket.org/gamesparks/gamesparks-node-server-sdk

If anyone has a tutorial about setting up server/client with Unreal and blueprints for Gamesparks, please share! Thanks

That wont be possible because you need to setup a node.js server on Amazon side and creating a new account on Amazon requires credit card information and all that.

Thank you Josh! :). One quick question. Any code wrapped inside #if UE_SERVER will disappear if I cook and package the game for WindowsNoEditor right?

AFAIK GameSparks does not offer a way to host your own dedicated server exe but recently they announced their realtime services. @PatGameSparks can help you :slight_smile:

Client and Server.

That is what I used to setup my node.js server on Amazon server

Thanks Ryan, good info - i emailed them.

UE_SERVER is defined when compiling for the MyGameServer.exe executable. Cooking is really an orthogonal issue, but yes this binary does expect cooked server data.

So anything under UE_SERVER will disappear if I build as dedicated server…right?

Hi unit23,
Our Realtime SDK is currently in the final stages of testing for the Unreal Engine. Is this what you are looking for? Feel free to log a ticket with our support service over at / and we can answer all your questions.

Best Regards, .

Just the opposite UE_SERVER is 1 when compiling for dedicated server. See Build.h for all the details.

@ryanjon2040,
UGameSparksComponent is a USceneComponent. so it have to be added as an component of another scene actor . problem is that whenever i load a new level that scene actor gets deleted . so connection between ue4 app and gamespark also gets reset.
how to prevent that?
anyway to not to delete the scene UGameSparksComponent’s parent?

@Muzaheed

You need to save your GameSparksComponent in GameInstance class. For my game what I did was I created GameSparks Component in my base game mode (from this I derive all other game modes) under constructor and inside InitGame function I save the GameSparksComponent in Game Instance class. This way, I never get lost of GameSparks connection throughout the game.

Here’s a quick example:

AExampleGameMode.h


UPROPERTY()
UGameSparksComponent* GameSparksComponent;

UPROPERTY()
UMyCustomGameInstance* MyCustomGameInstance;

virtual void InitGame(const FString& MapName, const FString& Options, FString& ErrorMessage) override;

AExampleGameMode.cpp


// In constructor
GameSparksComponent = CreateDefaultSubobject<UGameSparksComponent>(TEXT("GameSparksComponent"));
GameSparksComponent->SetupAttachment(RootComponent);

void AExampleGameMode::InitGame(const FString& MapName, const FString& Options, FString& ErrorMessage)
{
    Super::InitGame(MapName, Options, ErrorMessage);    
    MyCustomGameInstance = Cast<UMyCustomGameInstance>(GetWorld()->GetGameInstance());
    MyCustomGameInstance->SetupGameSparksComponent(GameSparksComponent);    
}

UMyCustomGameInstance.h


UGameSparksComponent* GameSparksComponent;

void SetupGameSparksComponent(UGameSparksComponent* NewComponent);

UMyCustomGameInstance.cpp


if (GameSparksComponent == nullptr)
{
    GameSparksComponent = NewComponent;
    // GameSparksComponent->OnGameSparksAvailableDelegate.AddDynamic(this, &UMyCustomGameInstance::OnGameSparksConnected); // Bind your delegate
}

I worked around it, using only one gamemode and one player controller.

After initial login, after the player leaves the login area and begins playing i set a bool, and check on the gamemode eventbeginplay if it was already set, if yes, the gamespark disconnect/connect and loading of the login view is skipped. The menu is accessible from within the game, so once the game begins, the player can do everything anyway. I can always load a different level and hide the player from the view if required. Not sure if this yields other problems, but so far seems to work for my approach.

@ryanjon2040, do that technique works on both side of host server and client ?

where did u keep your code for game spark’s BlueprintAssignable(listener and game spark component both have these events) events ?

so far i tried to keep them in actor and gamemode.

i got same result for both place.
they work as long as i am in single player mode. or i am the one who hosting the game.

but on client side whenever client join to a session and a new world gets loaded then the GameMode and actor both get deleted. so i lose all my data stored in there and also the code.

any idea?