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.