這個匹配系統是指一個玩家,可以創建一個自己隨意命名的房間,然后其他玩家可以通過聯網去搜索房間,然后加入房間一起游戲
我先講講怎么使用這個匹配系統:
在運行游戲后,因為添加了Network Manager HUD組件,所以有系統自帶的UI界面,如何進行匹配呢?
點擊最下方的Enable Match Maker按鈕,有一個可以輸入的文本框,前面的laber寫著"Room Name:",所以在這文本框中輸入的即是房間的名稱,然后點擊上面的Create Internet Match 即可創建房間。
在?"Room Name:"下方有一個Find Internet Match即可尋找房間,找到自己想加入的房間,點擊即可加入房間進行游戲。
接下來讓我們進入正題,這種東西還是得看用戶手冊:
Setting up the Multiplayer service
Before you can use the Matchmaker or the internet services you need to register the project first. See the Services Window (cloud icon in upper right corner, or go to Window->Unity Services in the application menu) where the Multiplayer panel should appear. In there you’ll find a link to the cloud Multiplayer website (you can also visit?https://multiplayer.unity3d.com?directly). Find your project name there and set up the Multiplayer configuration.
Note about Unity 5.1.x: The project ID is set up manually in this version of Unity, you can find the field for it in the Player settings (Edit -> Project Settings -> Player). Visit?https://multiplayer.unity3d.com?and set up your project manually and create a Multiplayer configuration for it. When viewing the configuration you’ll be able to see the ID (it’s called UPID right now in a 12345678–1234–1234–1234–123456789ABC format).
這是unity5.3的用戶手冊,可以發現5.3和5.1的操作是不一樣的,其他的版本會不會也不一樣我就不大清楚了,還請各位觀眾老爺自行查查手冊在這我就簡單說說5.3和5.1的設置方法,具體的詳見上面的英文版。
5.3版本:第一步需要先注冊你的項目,在unity的菜單欄上找到Windows->Services,在彈出的面板中可以找到多人玩家的網址(或者直接訪問?https://multiplayer.unity3d.com),找到你的項目,并設置多人游戲的配置(主要就是設置下每個房間最多的玩家數量)
5.1版本:同5.3,訪問?https://multiplayer.unity3d.com,找到你的項目然后設置其配置,然后在配置中你可以看到你項目的ID(一個類似于12345678–1234–1234–1234–123456789ABC這樣的格式的叫做UPID的東西),復制這一ID,在Edit -> Project Settings -> Player中填入此ID即可。
至此就可以使用簡單的匹配功能了,目前的問題就是延遲和丟包率,后續看看能不能有好的解決方法。