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

Yes.

In my custom Game Instance class.

Game Mode doesn’t exist on clients. If you try to cast your game mode in client it will always return null. If you want data throughout the entire game (i.e: even after loading new level) you need to save your data inside Game Instance because they exist till you exit the game completely.

i have tried your code sample.
sadly in 4.11, whenever a new level was loading the UGameSparksComponent stored in UMyCustomGameInstance was getting delated. and a new one was created by new AExampleGameMode() and was stored in UMyCustomGameInstance .
and i dont want that.
may be it works differently in latest version of ue4.

no idea. how the UGameSparksComponent was getting survived on client side during joining to server.
from my knowledge ,all sceneComponent supposed to be getting collected by garbage collector.
hence no sceneComponent can survive on client side.
and sadly UGameSparksComponent is a sceneComponent .

i dediced to modify the GameSparks plugin as it’s source code available. and i hope i will be able to make it bypass garbage collection.

anyway thanks for all the answers

For the GameSparksComponent in your GameInstance class, did you mark it as UPROPERTY()?

like this for example:



UPROPERTY()
UGameSparksComponent* GameSparksComponent;


yes.

here in the video i showed what is happening with that sample code.

[video]https://youtu.be/5M16p-X8LyM[/video]

I also have attached the source code of gamemmode , game instance and modefied version of my UGameSparksComponent.

basically , to detect if existing UGameSparksComponent is a new one or previous one , i have added this variable in it :

and then in UMyCustomGameInstance i was continuously printing the UGameSparksComponent stored in UMyCustomGameInstance 's
UGameSparksComponent* GameSparksComponent pointer.

in the video u will see that after hosting the GameSparksComponent gets cleared by garbage collector and set to null.

anyway, i have figure out a solution by modifying the gamespark plugin. most probably i will send them a pull request too.

If you dont want GameSparksComponent getting garbage collected then you should remove UPROPERTY() from it. If you look at my code example above you can see I never added UPROPERTY() for GameSparksComponent in GameInstance class.

Change from this:



UPROPERTY()
UGameSparksComponent* GameSparksComponent;


to this:



UGameSparksComponent* GameSparksComponent;


See attachment also.

actually i was given the opposite concept.
i added that UPROPERTY based on this line:
https://wiki.unrealengine.com/UPROPERTY

"Garbage Collection

Any Object that has at least one valid pointer stored inside a UPROPERTY will not be Garbage Collected (GC)."

Also i was informed:

"

still i did the test after removing UPROPERTY .
now it is crashing while checking.
Bcz it is now null.
strange part is that it is not giving true for (if (GameSparksComponent == nullptr))
No idea.why

Thanks for this, it’s incredibly relevant to me, and I’ll probably have some questions for you soon.

How have you handled horizontal scaling in your AWS instance with regards to talking back to Gamesparks? Was there much work required or was it “automagic” based on your AWS setup?

u have to do it by yourself. there are some open source tools for it.
the only thing in this matter GS helps is that it can provide u how many player is playing on each server. also GS can help u by providing player geographical location.

bump + following. I have been trying to find solution its almost been 2 weeks now.

are there any video tutorials for this out there yet?
the community would thrive from some solid videos on this subject