Download

Server Screws Up Client!

I can’t get the client working properly.

These are replicated rain drop blueprint actors. When they hit anything they are destroyed, and if they hit any players they increase a replicated moisture variable. This is displayed on the HUD as a meter which gradually lowers over time. The server works fine. However when the drops hit the client players, the meter increases as its supposed to. Then suddenly the meter jumps down to the same level as the server’s meter.

I know that the server is interfering with the client. However I can’t figure how to prevent this. I’ve tried countless configurations and everything ends up with the server constantly screwing up the clients. This was the best configuration I could come up with. I’m using a listen server set up.

What am I doing wrong? Thanks!

Here are 3 screenshots showing other code which is effecting the moisture variable. This is code I took from a tutorial and modified for my purposes. So, I don’t really understand why the code was set up the way it was. Ignoring the easy builder code (Unreal Asset), and spawning clouds (my code), the general idea is that a function on a timer every 2 seconds decreases the moisture meter by -1 unit. The moisture variable is replicated. This was how it was assigned in the tutorial. I don’t really know why they used replicated instead of RepNotify.

I’ll try to explain what I perceive the code to be doing. Begin play is routed to Is Locally Controlled. I’m presuming this like isServer is a conditional which only allows server logic. Therefore, all code after it will be restricted to the server. Yet, I don’t understand why is locally controlled was used instead of isServer in this situation? To me they appear to do the same thing. Then the function ReduceStats is called every 2 seconds. When ReduceStats is called the parameters of type and value are created on a server event. Why they are created on a server event also confuses me. I thought everything after the Is Locally Controlled would be on the server. But, I don’t understand server client program flow so I guess that’s why it appears redundant to me. The server event AddStats then passes the parameters to the server event AddStats. Once again this confuses me. Why pass the parameters to itself? If it already has the parameters, why not just modify the parameters in the the first AddStats event? From my perspective the red AddStats event is the same as the blue AddStats event? This is often what trips me up in replication, I don’t know when and where to use blue events vs red events especially when they are the same event. Finally in AddStats the parameter value is passed into the moisture variable where it is added to and clamped by the moisture max variable.

I understand the general concept of everything that’s going on. Yet, I have no idea why its structured the way it is. Note, I do remember the creator of the code saying we can plug in a list of items such as food, first aid kits, etc by type into this system. Maybe that’s why its structured in a more complex way than I would presume.

I figured by exposing this code, you’d have a better idea what the origins of my moisture variable are and what’s modifying it. Perhaps, there is something simple I’m missing due to being inexperienced with replication.

I figured it out!!!

I was pushing myself too hard, and had to take a break from it. In the mean time I read Cedrix’s Network Compendium, and watched Bry’s replication Youtube series. I found both of these sources to be more effective than the typical Youtube replication video. I also kept going back and rereading your posts. I’m gradually trying to piece together what they are saying with what you have been saying. I also recently purchased the multiplayer survival template. I needed some code which I could analyze. Goodness that code is complicated for doing something as simple as modifying progress bars. I really need to learn how to start implementing interfaces with multiplayer.

I understand now what you meant about passing parameters to the server. Up until this point I never had any use for passing parameters, I just used events to trigger code. I also noticed when studying the multiplayer template’s code he used a lot of switch has authority, and server events. I didn’t see any multicast events. I also noticed that he marked a lot of his server events as reliable. On his discord I saw him talking about marking events as reliable. I believe he said he marks nearly all his events as reliable with the exception of events which trigger too often such as tick.

You are correct the moisture variable needs to be clamped. I had noticed that earlier, but I was so focused on getting my replication to work that I forgot about that. Also, the cloud spawning code is mine. I was confused cuz when I play tested each player had a cloud over them, but when I moved and the cloud moved too, I could had sworn I saw 2 clouds jerk into place. It didn’t matter to me as long as I had a cloud which could spawn rain over each player, I was happy.

I’m still struggling to understand some of what your saying. But, I believe that’s cuz you have implemented replication in a variety of ways which I’m not familiar with such as with vehicles, aircraft, projectiles, etc. However I’m copying these messages for future reference. Cuz I’m sure they will come in handy whenever I start dealing with more advanced replication scenarios.

Once again I appreciate all the help! If you are still around, I just thought you might like to know that I came up with a solution.