[英]command for object without authority mirror
I having problems with unity mirror.我在使用统一镜像时遇到问题。 When respawn IEnumerator is called, the player respawn but it disconnect from the server, he cant move (only locally) and he cant do commands.当调用 respawn IEnumerator 时,玩家重生但它与服务器断开连接,他无法移动(仅在本地)并且他无法执行命令。 this is the respawn code:这是重生代码:
[Server]
IEnumerator Respawn(GameObject go){
print("Player ded");
NetworkServer.UnSpawn(go);
Transform newPos = NetworkManager.singleton.GetStartPosition();
go.transform.position = newPos.position;
go.transform.rotation = newPos.rotation;
yield return new WaitForSeconds(1f);
NetworkServer.Spawn(go);
}
Any solutions to that problem please?请问这个问题有什么解决办法吗?
I would need the whole script to make sure I am right, but I am pretty sure, that the problem is that you call [Server] via a client (which isn't allowed).我需要整个脚本来确保我是正确的,但我很确定,问题在于您通过客户端调用 [Server](这是不允许的)。
[Server] is used to make sure that only the server can call the function. [Server]用于确保只有服务器可以调用function。 Not a client, that would explain why the player is disconnected, when the function is called.不是客户端,这可以解释为什么在调用 function 时播放器会断开连接。
It would probably work if you change [Server] to [Command(requiresAuthority = false)].如果您将 [Server] 更改为 [Command(requiresAuthority = false)],它可能会起作用。 Link to the [Command] documentation: Mirror documentation If not please send the whole script.链接到 [Command] 文档: 镜像文档如果没有,请发送整个脚本。
With regards,带着敬意,
Aaron亚伦
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.