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.
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.
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.