Exemplo n.º 1
0
        /// <summary>
        /// 操作権を持つプレイヤー(Player1はホスト、
        /// Player2はクライアント)で呼び出されます。
        /// 操作をBoltEntityに渡します。
        /// </summary>
        public override void SimulateController()
        {
            IRollerBallBoltCommandInput input = RollerBallBoltCommand.Create();

            Vector3 data = new Vector3(_x, 0, _y);

            input.Mouse = data;

            entity.QueueInput(input);
        }
Exemplo n.º 2
0
        /// <summary>
        /// オブジェクトのオーナーで呼び出されます。
        /// これはPlayer1, 2ともにホストで呼び出されます。
        /// 入力を受け取って動かします。
        /// Player2からは、クライアントに結果を送信します。
        /// </summary>
        /// <param name="command">送られてきた操作コマンド</param>
        /// <param name="resetState">操作権を持っていたらtrue</param>
        public override void ExecuteCommand(Command command, bool resetState)
        {
            RollerBallBoltCommand cmd = (RollerBallBoltCommand)command;

            if (resetState)
            {
                // Player2。送られてきたコマンドのデータを反映させます
                transform.localPosition = cmd.Result.Position;
            }
            else
            {
                // 入力を使ってオブジェクトを動かします
                rb.velocity = cmd.Input.Mouse * input2Speed;

                // ホストとクライアントの双方で呼び出されます
                // 現在の座標を送信します
                cmd.Result.Position = transform.localPosition;
            }
        }