如何使用 Unity 中的 Photon 和骰子在棋盘游戏中创建回合制管理器?

问题描述

我遇到的问题是,当我将玩家 2 的骰子 SetActive 设置为 False 时,玩家 1 的骰子也会消失,因为 PhotonTargets 设置为 All 以便玩家令牌一起移动。下面是我如何尝试的代码。我什至需要在这里编写这个逻辑还是应该在其他地方?提前致谢

public static void MoveSteps(string playerName,int numberOfSteps)
    {
        ScriptsPhotonView.RPC("MoveStepsRPC",PhotonTargets.All,playerName,numberOfSteps); 
    }

    [PunRPC]
    void MoveStepsRPC(string playerName,int numberOfSteps)
    {
        print("playerName:" + playerName);
        print("numberOfSteps:" + numberOfSteps);
        

        if (playerName == "Player1")
        {
            GameObject.Find(playerName).GetComponent<PlayerController>().Move(numberOfSteps);
            dice.SetActive(true);
        }
        
        else if (playerName == "Player2")
        {
           dice.SetActive(false);
        }
    }

解决方法

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

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

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