Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

424
Views
No se puede usar el comando del servidor desde el cliente usando unity mirror

Estoy tratando de hacer un sistema inteligente de objetos utilizables.
Cuando el jugador se acerque a uno de los elementos utilizables, podrá presionar un botón y usar este elemento específico. todo funciona excepto la ejecución del comando use;

 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); } }

Y llamando a la función de uso así:

 [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); } }

Desde el objeto del jugador.
Al llamar a CmdEmergencyButton() no sucede nada excepto esta advertencia en la consola;
Haga clic para ver la advertencia

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

He intentado dar autoridad al cliente para usar el comando de este objeto (función de comentarios en uso) pero aún nada.
¿Alguna idea de por qué no funciona?

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!