Communicate on event - from an actor in a level instance to other clients
I have been looking for a way to . (each in their own level instance).
I have a persistent level that is basically empty (just lights etc) and I have 1 populated level that includes interactable actors. Running a dedicated server, all players are in the lobby. on Start each player creates his own level instance of the streaming level and is alone in that world. He can interact with the levers etc in his own world and it has no effect on any other players level Sort of non replication.
This is exactly as required for my "Relay Play" where player 1 will play the role of 1st signalman and using prototypical bells block instruments and levers to set the signals.. pass a train though his own level.
During passage of this train through the level player 1 will communicate and offer the service to player 2 and then he will pass on to player 3 etc etc.
All works as it should except for the fact that player 1 will need to know the status of an Interactable Block instrument in Player 2's Level.
So far I have not found a way to call Client2-> Level Instance-> Actors of Class Signalbox-> west blockset -> Pegger---State
This could be in level BP or Game instance
Any ideas greatly appreciated
a link to the single player demo which may give an idea https://www.youtube.com/watch?v=BWz4J5n6l8I
asked Nov 21 '17 at 08:15 PM in Blueprint Scripting
Hi. I think it will be better to use a common network game architecture where server stores the whole game state (It could be a replicated actor, GameState class or something else) and receives requests from players to perform some actions.
Each player have to spawn it's replication proxy with Replication and Only relevant to owner flags enabled. Server will see all of these objects but players will see only them personal instances. All communications between these objects should be implemented on a server side. Players can't change state of replicated objects because it's broadcasted from the server, so you have to use RunOnServer marked events to inform a server about player actions: For example, if you want player to turn the lever you have to send a "lever turning" request to the server and then wait for replication with new state of a lever instead of trying to turn a lever on a client. Really the best way is to inform a server only about player actions (player pressed "use") and evaluate feedback on a server - it protects against cheaters. Because of using asynchronous levels for playing it might be tricky: some players have train on their stations, some don't, and you can't just use tracing on a server side - it will give wrong result, but if it's not important for gameplay you can just ignore it (but there is possible glitches with collision). To avoid problems with hitting levers you can use static interaction areas which are independant from the levers position.
As result you will get something like this:
Player0 =[requests]=> Server (Player0 state) =[Interacts]=> Server(Player5 state) =[replicates]=> Player0, Player5
If you using separate replication agent you then have to copy state from this to the player level (actually turn levers, launch train arrival script etc.). With this architecture if player is disconnected or link is broken player will be able to walk around (if you don't replicate movement) but unable to push anything, but it seems normal for your game.
answered Nov 21 '17 at 10:28 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here