I’m trying to make a game where multiple clients can access an existing hosted world. I would like the clients to be able to enter the world with unique player pawn actors. This project is setup using the 3rd Person example blueprint and the default level. Everything is working as expected on the hosted server, however the client doesn’t behave correctly.
Here is my GameMode to create the actors, the issue is specifically that the ‘Cast to UserStats’ (Game State) seems to always grab the servers Game State and not the clients. (onPostLogin get game state, spawn pawn)
Here is my HUD to open the levels (on button click set Game State, Open Level)
Besides that I just have another Game State (called UserStats) with a single variable inside.
Again, everything is working correctly when I host a level and I can set my actor on level entry. When I join as a client, it seems like my client is picking up the servers Game State instead of using it’s own. This means the client can never be a unique actor and this is what I need to solve. Is there a way around this? Should I be using something instead of Game State for a networked Multiplayer game like this?
There’s no such thing as server game instance. Game instance is only local.
Game State, however, exists both on the server and on all clients. Maybe try using it instead?
Sorry for the incorrect text, I did in fact mean I am trying Game State and not Game Instance. I have corrected the original post to clarify.
OK so i’m super new and got confused and the original post as actually Game Instance and NOT Game State.
Based on the above answer I started looking into Game State vs Game Instance. I ended up using a Player State, and by modifying my blueprints like below I was able to get it working.
Replace the Game Instance with the Player State listed below. This Player State writes to a variable in Game Mode (Event must replicated on the Server)
Inside the game mode I just connected my variable to the same selection switch block as before.
Ultimately my issue was misunderstanding the Server-client structure and the fact that info flows from Server to Clients. I found the “print string” block to really help confirm which values were set on server vs client, and the following sites really helped break down the basics.
(38) Unreal Engine Networking and Multiplayer Games part 5 | LinkedIn
A Crash Course in Blueprint Replication (unrealengine.com)