无法使用统一镜像从客户端使用服务器命令

问题描述

我正在尝试制作一个智能可用的对象系统。
当玩家接近其中一个可用物品时,他将能够按下按钮并使用该特定物品。除了 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);
    }
}

并像这样调用 use 函数

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

来自玩家对象。
调用 CmdEmergencyButton() 时,除了控制台中的此警告外,没有任何反应;
Click to see warning

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

我已经尝试授权客户端使用来自这个对象的命令(使用函数中的注释),但仍然没有。
知道为什么它不起作用吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...