RPC not working on client when moving units
Hello everyone !
I'm trying to move a unit on a client and it's not working, while working perfectly fine on the server.
So my RTS Pawn has an array of selected actors, and will call the RPC for every single one of the unit (yeah, I know this is weird, I'm gonna change it but still). I use a BlueprintNativeEvent to link my C++ class with the BP child of that class (I use BP mostly for the viewport that C++ doesn't have T_T).
And inside my BP, I do that :
This is only working if the server uses it. If the client try to call it, it won't even call the "ROS Moving Unit". So the RPC is not even called. Instead, only the "BEFORE ROS" is printed.
My infantries are Characters set to replicates & movement replicates. When a unit is moving, both clients & server can see it.
My guess is that it's coming from ownership, but I'm really not certain how to fix it. The Barrack is supposed to have the right owner (my commander) and give it to the infantry on creation.
Thanks ! :)
I think you're right about the ownership. In order for a client to be able to call a RunOnServer event, that client's PlayerController must be the owner. In your case, the infantry units are controlled by the AIController that lives on the server. So that is the owner and because of this the client is not able to call the RPC on the infantry unit.
You could try to create something like a AIControllerManager. Each client should get one of these and it should be replicated so your clients can actually call RPCs and tell the server to call the Move To functions :)
Hope it helps, GL HF! ^^
answered Jan 30 '17 at 05:11 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here