Boss Room : unity sample
PhotonとUnity Relayどちらを使えば良いのかな?というところでとりあえず動かしてみます。
https://docs-multiplayer.unity3d.com/docs/learn/bossroom/index.html
co-op sample こちらをダウンロードしました。
![](https://grtlab.com/wp-content/uploads//2022/02/ss-2022-02-04-13.27.56-1024x98.png)
2020.3.27f1をインストールしました。
Photon realtime setting
Photone Realtimeでアプリケーションを作成
![](https://grtlab.com/wp-content/uploads//2022/02/ss-2022-02-04-13.35.57-1024x699.png)
![](https://grtlab.com/wp-content/uploads//2022/02/ss-2022-02-04-13.36.40.png)
アプリケーションIDを取得して Unity Projectに設定
Window > Photon Realtime > Wizard
Photon Cloud > Photon AppIDにコピーしたIDを入力してSetup!
Nextで進んで completeを表示してから閉じました。
![](https://grtlab.com/wp-content/uploads//2022/02/ss-2022-02-04-14.51.55-1024x800.png)
Assets / Photon / Resources の Photon App Settings で編集可能です。
![](https://grtlab.com/wp-content/uploads//2022/02/ss-2022-02-04-14.56.09.png)
パッケージをビルドした方が良いみたいです。
ビルド
boss.appとしてビルドして、2つ起動
open -n boss.app
で、mac は2つ起動できます。
HOSTになる
![](https://grtlab.com/wp-content/uploads//2022/02/ss-2022-02-05-3.40.27-1024x819.png)
START
![](https://grtlab.com/wp-content/uploads//2022/02/ss-2022-02-05-3.43.08-1024x585.png)
PHOTON RELAY を選択して、CONFIRM
![](https://grtlab.com/wp-content/uploads//2022/02/ss-2022-02-05-3.43.39.png)
HOSTが接続できて Room Nameが生成されました。
CLINET接続
STARTではなくJOINから開始
![](https://grtlab.com/wp-content/uploads//2022/02/ss-2022-02-05-3.45.17-1024x603.png)
PHOTON RELAY を選択 iphostとなっているところにHOSTで生成された Room nameを入力してJOIN
![](https://grtlab.com/wp-content/uploads//2022/02/ss-2022-02-05-3.45.45-1024x422.jpg)
![](https://grtlab.com/wp-content/uploads//2022/02/ss-2022-02-05-3.46.11-1024x423.jpg)
![](https://grtlab.com/wp-content/uploads//2022/02/ss-2022-02-05-3.47.42-1024x424.jpg)
Photon realtimeで接続できました^^
次にUnity Relayで接続してみます。
Unity Relay
と書いてあるけどよくわからないのでちょっと
こちらを見てみました。
Unity Game Servicesからプロジェクト設定、Unity Relay設定を行う
Projects > create project
![](https://grtlab.com/wp-content/uploads//2022/02/ss-2022-02-05-20.01.22.png)
Multiplayer > Unity Relay
![](https://grtlab.com/wp-content/uploads//2022/02/ss-2022-02-05-20.02.47-1024x917.png)
「Join Now」
![](https://grtlab.com/wp-content/uploads//2022/02/ss-2022-02-05-20.03.07-1024x805.png)
するとsettings の SDKダウンロードに移動します。
Packages/manifest.json をみると入ってるかわかります。
package manager の Relay Allocations が com.unity.services.relayのようで
まあ他のものも入っています。古かったら更新しておきます。
![](https://grtlab.com/wp-content/uploads//2022/02/ss-2022-02-05-20.13.30-1024x762.png)
Edit > Project Setting > Services
Organizations で自分の
![](https://grtlab.com/wp-content/uploads//2022/02/ss-2022-02-05-20.18.06-1024x457.png)
Use an existing Unity project IDを押すと
![](https://grtlab.com/wp-content/uploads//2022/02/ss-2022-02-05-20.19.41-1-1024x506.png)
Organizationsと Projects を game service で作成したものを設定
Link project ID をクリック
![](https://grtlab.com/wp-content/uploads//2022/02/ss-2022-02-05-20.28.14.png)
![](https://grtlab.com/wp-content/uploads//2022/02/ss-2022-02-05-20.28.31-1-1024x649.png)
設定完了のようです。
![](https://grtlab.com/wp-content/uploads//2022/02/ss-2022-02-05-20.23.03-1024x483.png)
nextで進んで Activate Relay – > Relay On にするとOKみたいです。
Unity Relay ビルドして実行してみます。
HOST
START > UNITY RELAY > CONFIRM で HOST接続
![](https://grtlab.com/wp-content/uploads//2022/02/ss-2022-02-05-20.34.22-1024x563.png)
CLIENT
Join > UNITY RELAY > join codeにHOST側のコードを入れてJOIN
![](https://grtlab.com/wp-content/uploads//2022/02/ss-2022-02-05-20.36.11-1024x581.png)
![](https://grtlab.com/wp-content/uploads//2022/02/ss-2022-02-05-20.37.59-1024x500.jpg)
2 players connected になりました!
次はロビーのサンプルもやらないとですかね・・・HOST作ってみんな待っていても仕方ないので順番に入っていく感じがいいのかな?
コネクションが切れた時の対応も必要ですね
やることは多そうです・・・
コメント