Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

423
Vistas
Unable to use server command from client using unity mirror

Im trying to make a smart usable object system.
When the player is getting close to one of the usable items he will be able to press a button and use this specific item. everything works except for the use command execution;

using UnityEngine;
using Mirror;

public class Usable : NetworkBehaviour
{
    public void Use(GameObject[] allUsables, Player CurrentClient, GameObject[] vents = null)
    {
        if (CurrentClient.isLocalPlayer)
        {
            //this.GetComponent<NetworkIdentity>().AssignClientAuthority(CurrentClient.GetComponent<NetworkIdentity>().connectionToClient);
            switch (this.name)
            {
                case string name when name.Contains("EmergencyButton"):
                    Debug.Log("Reached Log Point");
                    CmdEmergencyButton();
                    break;
                default:
                    Debug.LogError("Not possible!");
                    break;
            }
            //this.GetComponent<NetworkIdentity>().RemoveClientAuthority();
        }
    }

    [Command]
    private void CmdEmergencyButton()
    {
        RpcEmergency();
    }

    [ClientRpc]
    private void RpcEmergency()
    {
        //Activates emergency button effect
        GameObject.Find("EmergencyButton").transform.GetChild(0).gameObject.SetActive(true);
    }
}

And calling the use function like this:

[Client]
void ActivateUse()
{
    if(isLocalPlayer)
    {
        Debug.Log("Client using");
        //currUsables has all the nearby usable objects
        GameObject currentToUse = GameObject.Find(currUsables[0].name);
        //Using that object.
        currentToUse.GetComponent<Usable>().Use(allUsables, this, allVents);
    }
}

From player object.
When calling CmdEmergencyButton() nothing happens except for this warning in the console;
Click to see warning

Trying to send command for object without authority. Usable.CmdEmergencyButton
UnityEngine.Logger:Log(LogType, Object)

I have tried giving authority to the client to use command from this object (comments in use function) but still nothing.
Any idea why it doesn't work?

over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda