Though if you were passing both the variable to set AND the value you’d just do this instead:
boolToSet = val;
In the calling code and not bother calling that rather redundant method I showed.
I’m not very familiar with UNET at all, but if this is a variable that everyone needs to know about I think what your are looking for is [SyncVar] I believe you can something like this:
public class Settings : NetworkBehaviour
{
[SyncVar]
public bool QuickShotEnabled = true;
}
The server then updates this variable to all the clients when it changes. I’m sure there some good tutorials over in the Tutorials section on Unity’s site dealing with using SyncVar in games.
And if that doesn’t get you what you need there is also a UNET forum specifically UNET questions where some more experienced UNET guys could help you with your exact problem.
Hi ! Thank you for the quick reply.
I can’t test it right now but I’m pretty sure I already tried that out and if I remember correctly you can’t pass a ref keyword in a [Command]
( the var needs to be changed ON the server to be synced with clients, so you really need the [Command] attribute.
I’m pretty sure thats what SyncVar is for. If a client changes the var it will alert the server to change its value and push that value to all the clients (effectively Trying to set it through command but its all handled behind the scenes)