Replication: I am at a loss... why would the host client replicate 'client only' events?

If you are reading this, thank you!

I am about to go insane. I cannot seem to be able to get the host client to not replicate moving a mesh from one actor to another. Here is the rundown:

1). I have a TPS / FPS system where the player presses a key and the view changes

2). When you to from TPS to FPS, the system will detect which weapon / item is equipped and detach it from the TPS Mesh and attach it to the FPS arms, then it hides the mesh and all of its attachments. THIS SHOULD HAPPEN LOCALLY ONLY. Then the other clients still see your weapon attached to the 3rd person mesh no matter which view you are in.

3). The opposite happens when you move from FPS to TPS. Again, this happens locally and should not effect other clients.

Here are the issues I am having, and I cannot for the life of me figure out…

a). Any and all ‘actual’ clients work as expected. Anytime a view change happens, it happens locally to the client, and all other players, including the host, continue to see the item equipped on the 3rd person mesh.

b). However, when the host client changes from TPS to FPS (which is where it is supposed to LOCALLY detach the item from the 3rd person mesh and attach it to the FPS mesh) it is replicating. For all other clients, it shows that the item is disconnected from the 3rd person mesh.

c). This is all triggered from an InputAction. This isn’t starting from a ‘server’ event/function in the first place… wth???

Please, network gods of unreal, please help me!

Hi there,
Can’t say for sure without proper examination of your code, but looks like you code only allows clients to perform the switching. So, right after the input event, have you checked network authority with a “switch has authority” node? If the host is in the server, it may fail to execute the code. Also, the correct way to check replication is packaging your game (exe file) and playing with two computers.
You can add “print screens” nodes and see the differences between clients and host. Also, checking witha branch with “is locally controlled” AND “is local player controller” also is useful to check network authority. Hopefully, some senior dev will help you out.

Hey L.F.A.,

I have tried the switch has authority, and it was acting as you said… ‘host’ player has authority, and client players do not. I think this is the crux of my question/problem…

IF you are the host/server, and the client (listen server), how do you do something as if ‘you are just a client’ ? switch has authority, is locally controlled, and is local player controller would all give results as if you are the server when you are playing as the ‘player host’, correct? How could I fool my host players event to not replicate to other clients, therefore acting as if it is a pure client and not also the server?

What I have not done is package it and try it on two computers… working on that now and will post back.

Great if you can package and test it. I am not expert in multiplayer, but for me, your code doesn’t match with a familiar multiplayer setup. Typically, I would call switch has authority. If so, call a custom event replicated on owning client. Else, call a custom event replicated on the server which then calls the one replicated in the owning client. Alternatively, I would use the multicast + repnotify setup, which I’ve learned is more efficent, and also updates all future players who join the match later on.

Hey L.F.A … sorry for the delay in getting back here with the results.

So, I did the packaging test. Still the same issue. I refactored the code to do exactly what you suggested, following normal authority pattern checking, re-packaged, re-tested using different computers, still no dice.

I just kind of gave up for now. I am telling myself that it is something else with the character setup. The game I am working on was always intended to be played on a dedicated server or single player, but I was hoping to incorporate LAN as well, and that is where my main problem lies. If I ever want to do local hosted servers I have to figure this out, so I will likely come back to it in the coming months and try and get to the bottom of it. But I spent 3-4 days, roped you in, and still couldn’t get past it.

So I ripped off the band-aid and set up my dedicated servers. It took about 2 days to get it all up and running (digital ocean was awesome for this) but it is done now and when I connect with 2 computers, where each is a client, everything works flawlessly. Stranger things…

Anyway, thanks for the help! Just wanted to give you an update so I didn’t leave you hanging.

1 Like

Hi there,
Glad to know you are moving forward with dedicated server.

If you want a suggestion for a good multiplayer series, here is the playlist. Perhaps this series can give you insights on replication-related topics.

Good luck in your projects and keep uo the good work.

I’ve just hit the same problem. I have some experience with writing for dedicated servers and I find writing listen server functionality very confusing.

What you and I have is expected behavior; if something is happening on the host client (the listen server), even if it’s through a Client RPC or an Owner Only RepNotify, it doesn’t matter - it ultimately runs on the server, because the “client” in this case is THE server.

You put it very nicely, “as if the server is just another client”… no idea how to do that. I am almost considering scrapping this project and starting a new one. I can’t afford running dedicated servers.

In my game, players can press space or ctrl to move up or down the floors of the map. As we change the floor we hide everything above that floor. This works correctly for clients, but as soon as the serving player changes floors, the hiding/unhiding events run on every client as well.

Spent a week trying to figure this out but to no avail – any insight would be much appreciated!

No simple solution for listen servers in general, but for your visibility problem you could manipulate components bHiddenInGame flag, which is not replicated.

I am sorry, I have just seen this.

a). I totally understand how you feel about starting a whole new project!

b). I hope you didn’t!

c). I eventually got it all figured out. More on that below.

d). Note on dedicated servers. I am using a marketplace plugin called ‘Multiplayer Server Browser - Master Server - Server Listing’ … it took me probably 2-3 days to get it all set up and working, but using this I have 2 digital ocean instances (one for session listing and one for actually hosting games) and my monthly bill is ~ $15. Its a cost, but not breaking the bank. I have no idea what it will look like when I need to start scaling it. It is cool and easy to implement, and cost effective compared to some other setups. Just FYI.

Notes on this particular problem:

I can’t tell you exactly how I got this solved, but I DID get it solved. Here is my setup:

Multiplayer FPS and TPS. I don’t like True TPS (camera attached to 3rd person mesh head) for FPS games, it makes it feel like the character is floating around. So in my project, similar to like COD, the FPS mode has its own dedicated Arms mesh and camera setup etc. You can change between FPS and TPS anytime (PITA!).

So, that setup is complicated for replication it turns out lol! For instance, the players TPS mesh needs to be visible to all other players, all the time. But when the player changes their view from TPS to FPS, and the TPS mesh hides, it STILL needs to show for the other players but NOT for the controlling player. The way unreal handles visibility replication is confusing and complicated. Also, testing inside the editor in different modes with different amounts of players changes how your code will act. Sometimes player 1 (host) and player 2 all see everything correctly, and player 3 (client 2) doesn’t. Or sometimes dedicated hosting some players see the right things some dont.

Then there are weapons. Each weapon pickup has 2 meshes, 1 for TPS and one for FPS. All of the visibility issues that are there with the character meshes are there for the weapons. etc etc.

What eventually got me through it was an immense amount of trial and error. I posted this probably a month into my struggles, and it was probably another month before I got it all sorted. Then another 2 weeks straight on weapon attachments (another PITA!). Spawning, attaching, and changing visibility for different players in different circumstances is a pain! And the way the server acts also matters. I have found that I had to use delays here and there to make sure that the server had time to spawn the item before I was trying to attach it, etc. That really helped. when I realized that sometimes my problems were not code related but they were simply not working because the server needed a quarter second to finish its task before running further logic. Then a healthy use of client, server, and multi casting! And a healthy use of ‘isDedicated’ and ‘isServer’ and ‘isLocallyControlled’ etc.

Sorry this is kind of a book, but this is a BIG topic that will take a lot of your time, but it is TOTALLY worth it. I am really glad I stuck to it and pushed through. I learned a lot and I have reused some of the things I have learned in other replication issues, like flash lights. Getting the right light to show for the right scenario will make you pull your hair out!