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

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

新規登録して質問してみよう
ただいま回答率
85.46%
Unity

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

Q&A

0回答

1078閲覧

unity PUN2で所有権譲渡したときにエラー出る

退会済みユーザー

退会済みユーザー

総合スコア0

Unity

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

0グッド

0クリップ

投稿2020/02/14 16:34

編集2020/02/14 16:36

現状

順番で物を積み上げるゲームで所有権譲ることはできているがエラーが出てしまう
オブジェクトのphoton viewはtake over
alphabetgeneratorのトリガーコライダから出ていったときに所有権譲渡している

実現したいこと

エラー出ずに所有権を譲ってゲームを進めたい

エラーコード

NotImplementedException: The method or operation is not implemented.
AlphabetGeneratorOnline.Photon.Pun.IPunOwnershipCallbacks.OnOwnershipTransfered (Photon.Pun.PhotonView targetView, Photon.Realtime.Player previousOwner) (at Assets/Scripts/Online/AlphabetGeneratorOnline.cs:286)
Photon.Pun.PhotonNetwork.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:2188)

requestedView.OwnershipTransfer was ignored!
UnityEngine.Debug:LogWarning(Object)
Photon.Pun.PhotonNetwork:OnEvent(EventData) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:2195)
Photon.Realtime.LoadBalancingClient:OnEvent(EventData) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2826)
ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(StreamBuffer) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PeerBase.cs:656)
ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands() (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/EnetPeer.cs:549)
ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands() (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PhotonPeer.cs:1598)
Photon.Pun.PhotonHandler:Dispatch() (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:205)
Photon.Pun.PhotonHandler:FixedUpdate() (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:139)

該当コード

unity

1コード 2public class AlphabetGeneratorOnline : MonoBehaviourPunCallbacks, IPunOwnershipCallbacks 3{ 4 public Camera mainCamera; 5 public static int alphabetNum = 0; 6 public bool isGameOver; 7 private GameObject genealpha; 8 public GameObject Rotatebutton; 9 public bool isGene; 10 public bool isFall; 11 private int count; 12 Rigidbody2D rigid2D; 13 GameObject gameController; 14 int number; 15 16 // Start is called before the first frame update 17 void Start() 18 { 19 Reset(); 20 rigid2D = GetComponent<Rigidbody2D>(); 21 //開始時にgamecontrollerを見つける 22 gameController = GameObject.FindWithTag("GameController"); 23 PhotonNetwork.AddCallbackTarget(this); 24 25 } 26 27 public void Reset() 28 { 29 alphabetNum = 0; 30 isGameOver = false; 31 Move.isMoves.Clear(); 32 StartCoroutine(StateReset()); 33 } 34 35 // Update is called once per frame 36 void Update() 37 { 38 if (!photonView.IsMine) 39 { 40 Rotatebutton.SetActive(false); 41 } 42 if (photonView.IsMine) 43 { 44 Rotatebutton.SetActive(true); 45 if (isGameOver) 46 { 47 return; 48 } 49 if (MoveCheck(Move.isMoves)) 50 { 51 return; 52 } 53 if (!isGene) 54 { 55 if (rigid2D.velocity.magnitude == 0) 56 { 57 Invoke("GenerateAlphabet", 0.5f); 58 isGene = true; 59 } 60 } 61 if (genealpha == null) 62 { 63 return; 64 65 } 66 else 67 { 68 Vector2 v = new Vector2(mainCamera.ScreenToWorldPoint(Input.mousePosition).x, transform.position.y); 69 70 if (Input.GetMouseButtonUp(0)) 71 { 72 73 if (!RotateButton.onButtonDown) 74 { 75 genealpha.GetComponent<Rigidbody2D>().isKinematic = false; 76 alphabetNum++; 77 isFall = true; 78 genealpha.GetComponent<Rigidbody2D>().gravityScale = 1; 79 } 80 RotateButton.onButtonDown = false; 81 82 } 83 if (Input.GetMouseButton(0)) 84 { 85 genealpha.transform.position = v; 86 } 87 } 88 89 } 90 } 91 92 IEnumerator StateReset() 93 { 94 while (!isGameOver) 95 { 96 yield return new WaitUntil(() => isFall); 97 yield return new WaitForSeconds(0.1f); 98 isFall = false; 99 isGene = false; 100 } 101 } 102 103 public void GenerateAlphabet() 104 { 105 if (count == 0) 106 { 107 // 1から100までの中からランダムに数字を選択する。 108 number = Random.Range(1, 26); 109 if (number == 1) 110 { 111 genealpha = PhotonNetwork.Instantiate("A", transform.position, Quaternion.identity); 112 } 113 114 genealpha.GetComponent<Rigidbody2D>().isKinematic = true; 115 gameController.SendMessage("IncreaseScore"); 116 } 117 } 118 119 120 public void RotateAlphabet() 121 { 122 if (!isFall) 123 { 124 genealpha.transform.Rotate(0, 0, -30); 125 } 126 } 127 128 bool MoveCheck(List<Move.Moving> isMoves) 129 { 130 if (isMoves == null) 131 { 132 return false; 133 } 134 foreach (Move.Moving b in isMoves) 135 { 136 if (b.isMove) 137 { 138 isGene = true; 139 isFall = true; 140 return true; 141 } 142 } 143 return false; 144 } 145 146 public void OnTriggerStay2D(Collider2D collision) 147 { 148 if (collision.CompareTag("Alphabet") || collision.CompareTag("SetAlphabet")) 149 { 150 count = 1; 151 } 152 } 153 154 private void OnTriggerExit2D(Collider2D collision) 155 { 156 if (count == 1 && !photonView.IsMine) 157 { 158 photonView.RequestOwnership(); 159 } 160 count = 0; 161 } 162 163 164 public bool IsGameOver() 165 { 166 return isGameOver; 167 } 168 public void ReDead() 169 { 170 //ぶつかったらフラグを立てる 171 isGameOver = true; 172 } 173 174 void IPunOwnershipCallbacks.OnOwnershipRequest(PhotonView targetView, Player requestingPlayer) 175 { 176 throw new System.NotImplementedException(); 177 } 178 179 void IPunOwnershipCallbacks.OnOwnershipTransfered(PhotonView targetView, Player previousOwner) 180 { 181///////////////////////////////  286行目  //////////////////////////////////////// 182 throw new System.NotImplementedException(); 183////////////////////////////////////////////////////////////////////////////////////// 184 } 185}

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

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

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

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

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

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

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

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

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

ただいまの回答率
85.46%

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

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

質問する

関連した質問