Sync isActive to other Clients

what i want to do:

when client A presses a button, i want a child of the player character to become active for a short time.

what works so far:

when i press the button, i see the object become active on the client that presses the button and on the server.

i do it this way:

        //in Update
        if (Input.GetKeyDown(KeyCode.Space))
        {
            StartCoroutine(Slash());
        }
.

    IEnumerator Slash()
    {
        slashObject.SetActive(true);
        CmdSlashOn();
        yield return new WaitForSeconds(0.3F);
        slashObject.SetActive(false);
        CmdSlashOff();
    }
.

    [Command]
    void CmdSlashOn()
    {
        slashObject.SetActive(true);
    }

    [Command]
    void CmdSlashOff()
    {
        slashObject.SetActive(false);
    }

what i want and cannot figure out how to do:

if there are two clients connected to the server, i just see the object becoming active on the client that presses the button and on the server. the other client is NOT seing the object become active. how can i send the information about the isActive change to all other clients?

thanks for your help!

I’m having the same problem. So, bump? Is that how it works?

You have to call RPC function in the Command function.

Command : client → server
RPC : server → all clients

What if the object I want to disable has local player authority so when the Server tries to disable it for other clients it can’t because it doesn’t have authority?

Server has authority over everything, as that’s part of UNET. A client should only ever have access to its own player, while the server controls everything.

So pretty much, in both of your Commands you need to call an RPC that will basically tell the clients what to do. As is, you’re only telling the server and not the other clients that you activated.