美文网首页
Unity3d_Multiplayer Netwoking3

Unity3d_Multiplayer Netwoking3

作者: 慕城祉宇流年殇 | 来源:发表于2018-01-10 09:56 被阅读0次

    Setting up the Player prefab

    设置播放器预置。

    The Player prefab asset will represent the player, or players, in this example project.

    在这个示例项目中,玩家预置资产将代表玩家或玩家。

    By default, the NetworkManager component instantiates a GameObject for each player that connects to the networked game by cloning the player prefab and spawning the clone into the game.

    默认情况下,NetworkManager组件为每个连接到网络游戏的玩家实例化一个GameObject,通过克隆玩家预置程序并将克隆生成到游戏中。

    Network Spawning and the details of synchronizing player GameObjects over the Clients and Server will be covered later in this assignment.

    网络生成和在客户端和服务器上同步播放器游戏对象的详细信息将在稍后的作业中讨论。

    For this example, the player GameObject will be a simple Capsule with a “visor” so we know which way the capsule is facing.

    在这个例子中,玩家的游戏对象将是一个简单的带有“遮阳板”的胶囊,这样我们就知道了胶囊的朝向。

    The final Player GameObject in the scene should look like this.

    场景中的最后一个玩家游戏对象应该是这样的。

    场景中的最后一个玩家游戏对象

    To create this Player GameObject:

    要创建这个播放器游戏对象:

    Create a new Capsule primitive GameObject.

    创建一个新的胶囊原始游戏对象。

    Rename the new GameObject to “Player”

    将新游戏对象重命名为“Player”

    To indicate the “front” of the Player GameObject, so we know which way it is facing, add a small Cube to the Player GameObject as a child and color it black.

    为了表示玩家游戏对象的“正面”,我们知道它所面对的方向,将一个小方块添加到玩家的游戏对象中,并将其涂成黑色。

    With the Player GameObject selected,

    选择了玩家的游戏对象,

    ...

    create a new Cube primitive GameObject as a child of the Player GameObject.

    创建一个新的立方体原始游戏对象,作为游戏玩家的孩子。

    Rename the new GameObject “Visor”.

    重新命名新的GameObject“Visor”。

    Set the Visor GameObject’s Scale to (0.95, 0.25, 0.5).

    将Visor GameObject的Scale设置为(0.95,0.25,0.5)。

    Set the Visor GameObject’s Position to: (0.0, 0.5, 0.24).

    将Visor GameObject的位置设置为:(0.0,0.5,0.24)。

    Create a new Material.

    创建一个新的材料。

    Name this Material “Black”.

    这种材料“黑色”名称。

    With the Black Material selected,

    选择了黑色材料,

    ...

    change the Albedo color of the Material to black.

    把材料的反照颜色改为黑色。

    Set the Visor GameObject’s Material to the Black Material .

    将遮阳板的材质设置为黑色材料。

    To identify the Player as a unique Networked GameObject, add a NetworkIdentity to the Player.

    要将玩家识别为一个独特的网络游戏对象,可以向玩家添加一个NetworkIdentity。

    With the Player GameObject selected,

    选择了玩家的游戏对象,

    ...

    find and add the component: Network > NetworkIdentity.

    查找并添加组件:Network > NetworkIdentity。

    The NetworkIdentity component is used to identify the object on the Network and to make the Networking system aware of it.

    NetworkIdentity组件用于识别网络上的对象,并使网络系统知道它。

    For more information on the NetworkIdentity component, please see the page on NetworkIdentity.

    有关NetworkIdentity组件的更多信息,请参阅NetworkIdentity上的页面。

    Set the Local Player Authority checkbox on the NetworkIdentity to true.

    将NetworkIdentity上的本地播放权复选框设置为true。

    将NetworkIdentity上的本地播放权复选框设置为true。

    Setting the NetworkIdentity to Local Player Authority will allow the Client to control the movement of this Player GameObject.

    将NetworkIdentity设置为Local Player Authority将允许客户端控制该播放器的游戏对象的移动。

    Create a prefab from the Player GameObject

    从玩家的游戏对象中创建一个预置。

    Drag the Player GameObject into the Project window to create a new prefab asset.

    将Player GameObject拖到项目窗口中,创建一个新的预置资产。

    Delete the Player GameObject from the scene.

    从场景中删除玩家的游戏对象。

    Save the scene.

    保存场景。

    相关文章

      网友评论

          本文标题:Unity3d_Multiplayer Netwoking3

          本文链接:https://www.haomeiwen.com/subject/poinnxtx.html