I’ve been trying to make it so that when a specific dialogue option is selected on one machine, all currently-connected players are moved to the next level (together). I have the GameMode set up to use seamless transition (the one piece of C++ I’ve added to this project, since this isn’t visible through blueprints), and right now, it’s not working at all.
What I believe is the main problem is that our Dialogue class is currently set as the HUD, which means it only exists on the clients. This probably going to be redesigned, but I’m trying to work with it. If Dialogue itself calls OpenLevel, only that client moves (makes sense).
So my current goal is to have the function be called by the client but actually execute on the server. I appear to need to use a remote procedure call which seems to have to do with function replication. I created a custom event in Dialogue called OpenLevelOnServer that I set to replicate on server that just calls OpenLevel.
If I run this on a client, it does nothing, just ends the dialogue.
If I run it on a client-server, it sends the client-server to the specified room but sends the other connected client to the default starting room (which is in this case the main menu).
I’m sure I’m doing replication wrong in some manner. This game was not designed with multiplayer involved and I’m trying to add it after the prototype has been developed. I’m confused as to what the “replicate on server” option is doing if calling it from the client doesn’t work, though I guess it has something to do with the “if owning client” part of the event call. I’m also not sure why, when it’s called from the client-server, it seems to ignore the level name when moving the other client.
I ran the program with -log enabled, it it looks like when the client tries to change the level, it gives me an error “LogNet:Warning: Client is absorbing remote function OpenLevelOnServer on actor Dialogue_C_0 because RemoteRoll is ROLE_None”
When the client-server runs it, the log shows it closing the connection, and on the client-side, it registers the closed connection and defaults to opening the main menu.
I guess at this point, my questions are “Why does it close the connection when I have bUseSeamlessTransitions set to true?” and “How am I supposed to ask the server to run the OpenLevel function from the client?”
When I call the console command ServerTravel MapName (from the server), it works, and the console clearly logs it using seamless travel and going to the transition room and then the new level. If I interact with the object that calls the OpenLevel node, it clearly doesn’t use seamless travel in the console log. I tried changing the OpenLevel node to an “ExecuteConsoleCommand” one and it either crashes or disconnects.
EDIT3: Comments from Josh Markiewicz on the UE4 answer hub say that Open Level calls SetClientTravel which almost certainly is not the thing I want to do, since even if it’s called from the client-server, it’s calling it as a client. This probably explains why it’s disconnecting, assuming that seamless travel doesn’t work if it’s called from the client.
EDIT4: I’ve spent this entire time trying to fit a square peg into a round hole and finally realized I need an extra library to support this kind of multiplayer. Checking out Photon.