質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Photon Cloud

Photon Cloudは、オンラインゲーム開発向けネットワークエンジン。リアルタイムマルチプレイ通信のプラットフォームであるPhotonの一つです。ネットワーク通信によるオンラインゲームを開発・運営するために必要なツールがサーバー環境に構築されています。

Unity

Unityは、Unity Technologiesが開発・販売している、IDEを内蔵するゲームエンジンです。主にC#を用いたプログラミングでコンテンツの開発が可能です。

Q&A

0回答

1591閲覧

[Unity]PUN2で RPCメソッドが使えない

minokiti

総合スコア45

Photon Cloud

Photon Cloudは、オンラインゲーム開発向けネットワークエンジン。リアルタイムマルチプレイ通信のプラットフォームであるPhotonの一つです。ネットワーク通信によるオンラインゲームを開発・運営するために必要なツールがサーバー環境に構築されています。

Unity

Unityは、Unity Technologiesが開発・販売している、IDEを内蔵するゲームエンジンです。主にC#を用いたプログラミングでコンテンツの開発が可能です。

0グッド

0クリップ

投稿2021/04/30 06:32

編集2021/05/04 08:23

UnityでPUN2を使ってオンラインボードゲームを作っています。
ターンをそれぞれのプレイヤーで同期させようと思い、RPCを使おうとしましたが、エラーが出て使えません。

Console

1Assets/Scripts/TileMap.cs(95,30): error CS0121: 2The call is ambiguous between the following methods or properties: 3'PhotonView.RPC(string, object, string)' and 'PhotonView.RPC(string, RpcTarget, params object[])'

スクリプト

TileMap

1using System; 2using System.Collections; 3using System.Collections.Generic; 4using System.Linq; 5using UnityEngine; 6using UnityEngine.Tilemaps; 7using Photon; 8using Photon.Pun; 9using Photon.Realtime; 10 11public class TileMap : MonoBehaviourPunCallbacks, IPunObservable 12{ 13 [SerializeField] Tilemap tilemap = default; 14 15 public GameObject RedTile; 16 public GameObject BlueTile; 17 public bool HasTile = false; 18 public string turn = "Red"; 19 public Vector3Int[] PutTiles = new Vector3Int[0]; 20 21 private Vector3 screenToWorldPointPosition; 22 public NetworkManager networkManager; 23 public bool IsMyTurn; 24 PhotonView m_photonView = null; 25 26 private void Start() 27 { 28 m_photonView = GetComponent<PhotonView>(); 29 } 30 void Update() 31 { 32 Vector3 position; 33 // Vector3でマウス位置座標を取得する 34 position = Input.mousePosition; 35 // Z軸修正 36 position.z = 10; 37 // マウス位置座標をスクリーン座標からワールド座標に変換する 38 screenToWorldPointPosition = Camera.main.ScreenToWorldPoint(position); 39 40 if (turn == "Red") 41 { 42 Debug.Log("赤のターン"); 43 if (networkManager.Character == "Red") 44 { 45 IsMyTurn = true; 46 } 47 else 48 { 49 IsMyTurn = false; 50 } 51 } 52 53 if (turn == "Blue") 54 { 55 Debug.Log("青のターン"); 56 if (networkManager.Character == "Blue") 57 IsMyTurn = true; 58 else 59 IsMyTurn = false; 60 } 61 62 if (IsMyTurn) 63 { 64 if (Input.GetMouseButtonUp(0)) 65 { 66 // 座標情報を渡す 67 clickedPosition(screenToWorldPointPosition, turn); 68 } 69 } 70 } 71 72 public void clickedPosition(Vector3 position, string turnstr) 73 { 74 HasTile = tilemap.HasTile(tilemap.WorldToCell(position)); 75 if (HasTile && !(PutTiles.Contains(tilemap.WorldToCell(position)))) 76 { 77 Debug.Log($"{turn} putting a tile."); 78 Array.Resize(ref PutTiles, PutTiles.Length + 1); 79 PutTiles[PutTiles.Length - 1] = tilemap.WorldToCell(position); 80 if (turn == "Blue") 81 { 82 PhotonNetwork.Instantiate("Bluetile", tilemap.GetCellCenterWorld(tilemap.WorldToCell(position)), Quaternion.identity); 83 } 84 if (turn == "Red") 85 { 86 PhotonNetwork.Instantiate("Redtile", tilemap.GetCellCenterWorld(tilemap.WorldToCell(position)), Quaternion.identity); 87 } 88 89 if (turn == "Red") 90 { 91 turn = "Blue"; 92 } 93 else 94 { 95 turn = "Red"; 96 m_photonView.RPC("Change", RpcTarget.MasterClient, turn); //ここでエラー 97 } 98 } 99 } 100 101 public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) 102 { 103 if (stream.IsWriting) 104 { 105 stream.SendNext(turn); 106 } 107 else 108 { 109 turn = (string)stream.ReceiveNext(); 110 } 111 } 112 113 [PunRPC] 114 void Change(string turn_str) 115 { 116 turn = turn_str; 117 } 118} 119

「The call is ambiguous between the following methods or properties: 'PhotonView.RPC(string, object, string)' and 'PhotonView.RPC(string, RpcTarget, params object[])'」とあり、引数の間違いの可能性があると思ったのですが、コードを見る限り無さそうなので質問させていただきました。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問