How to use ReplicatedUsing and what is the intended behaviour from this?
I am trying to learn on the uses of “ReplicatedUsing” but I have tried it for many days and it is not doing what i have intended it to do. Perhaps i was wrong on the intended use of it.
Basically i have two c++ controllers (Server and Client), each will take their turn to switch on/off a light. So this light should be visible on both the server and client sides. However, regardless of what i have changed, only the light on client side was toggled.
The above was just some of the basic code. Could someone please guide a noob like thru this? I have been at this for days, stripping it bare or swapping "netmulticast, server … " and what is not! The strange thing about the ReplicatedUsing is that, the “directed function” aka LightTrigger() for this case, GetPlayerController(this,0) is always the client regardless of whether i am using the server or the client.
OnRep functions aren’t called on dedicated/listen servers, you should call it manually if needed.
Also you should have a ServerPressButton() that will set WhatOn on the server. You should only set replicated values on the server for an unconditional DOREPLIFETIME.
As far as I know the condition of Role == ROLE_Authority in LightTriggerZ_Implementation() will always be true, because the function is only executed in the server.