简体   繁体   English

没有播放器预制的Unity网络(C#)

[英]Unity networking without a player prefab (C#)

I would like to add multiplayer to my game. 我想将多人游戏添加到我的游戏中。 I use UMA ( https://www.assetstore.unity3d.com/en/#!/content/13930 ) to generate a character in a character creation scene. 我使用UMA( https://www.assetstore.unity3d.com/en/#!/content/13930 )在角色创建场景中生成角色。 I then use: 然后,我使用:

DontDestroyOnLoad(characterController);

To take the player to my main game scene. 将玩家带到我的主要游戏场景。 The UMA generated player cannot be made a prefab, cannot be duplicated or instantiated (not sure why but it doesn't work). UMA生成的播放器无法做为预制件,无法复制或实例化(不确定原因,但不起作用)。 So I then via script move the player to the spawn position where they can play the game. 因此,我然后通过脚本将玩家移动到生成位置,在该位置他们可以玩游戏。

I have made multiplayer games before, but in all of them I use 我以前做过多人游戏,但在所有游戏中我都使用

Network.Instantiate(playerPrefab);

to add the player to the game. 将玩家添加到游戏中。 The problem here is that I have no idea (nor could I find out online) how to implement multiplayer with a character ALREADY in the scene. 这里的问题是我不知道(也无法在线找到)如何在场景中实现具有角色角色的多人游戏。

Any help, ideas, advice or suggestions would help me out a lot ! 任何帮助,想法,建议或建议都会对我有很大帮助!

You can instantiate only the GameObject that has the scripts to control the player and search for the models generated by UMA which are already in the scene. 您只能实例化具有脚本的GameObject,该脚本可以控制玩家并搜索场景中已经存在的UMA生成的模型。

By the way, if you're using Unity 5.1 or newer Network.Instantiate is not used anymore. 顺便说一句,如果您使用的是Unity 5.1或更高版本的Network.Instantiate,则不再使用。 http://docs.unity3d.com/Manual/net-NetworkInstantiate.html http://docs.unity3d.com/Manual/net-NetworkInstantiate.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM