相关疑难解决方法(0)

在新的Unity网络中进行"直接"RPC样式调用?

说你有

在此输入图像描述

使用"新的"统一网络,你必须有(据我所知)一个NetworkManager地方.它会产生荒谬的"玩家"对象.

荒谬的"玩家"对象必须有一个继承自的类NetworkBehaviour.

大多数团队称该类为"Comms"或"AbstractPlayer"或"Junction".

public class Comms : NetworkBehaviour { }
Run Code Online (Sandbox Code Playgroud)

因此,每个命令(如"跳转")都必须由"Comms"类调解.

对于每个命令(如"Jump"),您需要 Comms类中的一对函数:

public class Comms : NetworkBehaviour {

    // for every command (say, "Jump") you need THIS PAIR of functions:

    public void CommandJump() {
        Debug.Log("this is comms - client, do a Jump");
        CmdJump();
    }

    [Command]
    void CmdJump() {
        Debug.Log("this is comms - server. a Jump arrived");
        // simply pass on that command to the correct script on a server... …
Run Code Online (Sandbox Code Playgroud)

networking unity-game-engine

4
推荐指数
1
解决办法
515
查看次数

标签 统计

networking ×1

unity-game-engine ×1