GameInstance to Level to GameMode
I have a question regarding the logical flow of events as they pertain to a multiplayer game. Specifically I would like to find out what is the sequence of events when a session is created / joined.
Let me first describe what I am currently doing
So now at this point I have two players 1 of which is the server sitting in the same map and they can see each other.
Now my issue is that the Lobby level has a custom LobbyGameMode associated with it
Inside of the game mode I have the following methods over written
Now with all this in place, none of my GameMode functions are being called. I haven't implemented them yet so all I am doing is just printing the method name as the Player would be accessing it. Example)
But again nothing gets printed to screen and it appears like none of the GameMode functions that should be called are being initalized
Further to that I also have a MainMenuGameMode and that one, for example, has PostLogin overwritten and gets called when the game starts up. I presume this is because a default GameInstance is being created and UE4 is just going through the motions of creating a baby server.
Both my MainMenu and Lobby level are created the same way where I have a Level Blueprint and a Level C++ class that overwrites the default behaviour. Also each level specifies their own custom game modes.
What I can see is when the players join and I try to print out which GameMode is being used I can see that it's correctly setting up my LobbyGameMode just not initiating any of the functions one would expect to be triggered.
I thought perhaps the reason was becase I was trying to do OpenLevel instead of another travel method but when I switched my logic to
The same result comes up where nothing on my LobbyGameMode is triggered.
Looking for advice how I can make this behave as expected.
My suspicion is that when the new Level is loaded the GameMode is not re-initialized but rather attached to the Level. Which makes me think I either need to trigger the re-initialization or there is a parameter somewhere I am not passing to either OpenLevel or ServerTravel.
The reason I need to get at the GameMode methods is pretty straight forward, I wanted to intercept Pre and PostLogin calls such that I can manipulate the PlayerController accordingly from changing the HUD to loading the appropriate user settings, etc etc
I appreciate any advice you guys can provide, Thanks.
In the spirit of not leaving questions hanging I finally found my solution. Basically somewhere between UE4 crashing my changes to the BP_LobbyGameMode blueprint my LobbyGameMode class was not saved as a parent.
Hence nothing was being called but after this little, yet frustrating, correction everything started working as expected.
answered Feb 10 '18 at 06:24 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here