要使用 NetworkManagerHUD 来集成 Unity Multiplayer 服务,请遵循以下步骤:
在场景中创建一个空游戏对象。
向空游戏对象添加 NetworkManager 和 NetworkManagerHUD 组件。将此对象重命名为“Network Manager”以表明其用途。
创建一个预制件来表示玩家。连接到游戏的玩家将分别控制此预制件的某个实例。
向玩家预制件添加 NetworkIdentity 和 NetworkTransform 组件。NetworkTransform 组件可同步玩家游戏对象的移动。如果要开发玩家不会移动的游戏,则不需要此组件。
在 Inspector 中,将玩家预制件添加到 Network Manager 的 Player Prefab 属性。
构建并运行项目。Network Manager HUD 将显示游戏内菜单。单击 Enable Match Maker。
在托管应用程序上选择一个房间名称并单击 Create Internet Match。
运行项目的更多实例,然后在这些客户端上单击 Find Internet Match。现在应该会显示房间名称。
单击 Join Match。玩家现在应该已经连接到同一个比赛。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.