# Mirror Networking; How to Pass/Sync c# actions?

Since you can not pass actions as parameters to commands and rpc calls, how would you sync actions ? My main goal is to find an easy and generic way for objects to easily do actions from their local player. Something like:

_localPlayer.RunFromLocalToAllPlayers(()=>
{
//MyAction
});


Local Player having these methods:

private Action _callbackForAllPlayers;
public void RunFromLocalPlayerToAllPlayers(Action callback)
{
_callbackForAllPlayers = callback;
Debug.Log(_callbackForAllPlayers);
CmdRunFromLocalPlayerToAllPlayers();
}

[Command]
private void CmdRunFromLocalPlayerToAllPlayers()
{
Debug.Log($"Running on server"); RpcRunFromLocalPlayer(); } [ClientRpc] private void RpcRunFromLocalPlayer() { Debug.Log($"Running on client");
_callbackForAllPlayers?.Invoke();
Debug.Log(_callbackForAllPlayers);
}


and of course that local Action variable is being null on other clients since i can not sync it or pass it as parameter.

• Why don't you just broadcast a RPC to all players? Jan 18 at 21:57
• Of course i can go straight and use different Commands and different RPC calls for every action but i am looking for an easy and generic solution to this thats why. Jan 18 at 22:01
• I don't think there is a better way to do that than broadcasting a RPC. That seems to be exactly the purpose of RPC's and where they should be used. Could you please expand more on why you want to avoid using RPCs in this case? Jan 18 at 22:05
• Thanks for your input. Jan 18 at 22:05
• I mean the question has my purpose and i already wrote my purpose with my first comment but here it is again, i am trying to find a generic solution for those kinda Command and RPC calls because otherwise whenever i would like to do something i have to write different command/rpc calls each time for every different action in the game. Jan 19 at 7:55