Can someone provide a quick example of how to create a function that will be executed on a dedicated server and then replicate a variable with the result. The hard thing for me is that the function must not be called on a client and then executed on a server but rather the server should start executing it when it starts.
What I am trying to do is call a function that calculates and updates the location of a planet. I need this to be executed on the server only and the resulting rotation and location to be replicated to the clients. Any help would be appreciated.
Currently, only the server replicates actors to connected clients (clients will never replicate actors to the server). With this in mind, ONLY the server should see Role == ROLE_Authority and RemoteRole == ROLE_SimulatedProxy or ROLE_AutonomousProxy.
Every actor has a Role and RemoteRole. You might be able to call the function AActor::HasAuthority() to see whether it has ROLE_Authority (I’m guessing that’s what it returns).
So in Tick ask if it has authority, if so you can update your replicated variable.