我正在测试Unet,现在在远程客户端上产生时遇到问题。所有工作都在服务器/客户端。
我有三个非玩家对象:我生成的“橙色”,“苹果”和“香蕉”。在我测试时,我使用非常基本的代码来执行此操作。但是,当产生时,只有两个对象产生,第三个得到以下错误:
无法生成服务器对象,assetId = 3bd88da3adcb74d04addd82122b34fee netId = 6 UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()
我一直在努力寻找解决方案,但这是我得到的唯一信息。我使用以下产生代码:
using UnityEngine;
using System.Collections;
using UnityEngine.Networking;
public class SpawnManager : NetworkBehaviour {
[SerializeField] GameObject Spawn1;
[SerializeField] GameObject Spawn2;
[SerializeField] GameObject Spawn3;
[SerializeField] GameObject Spawn4;
public override void OnStartServer() {
SpawnFruits ();
}
void SpawnFruits() {
GameObject goX = Resources.Load ("Apple") as GameObject;
GameObject goY = Resources.Load ("Orange") as GameObject;
GameObject goZ = Resources.Load ("Banana") as GameObject;
GameObject go1 = GameObject.Instantiate (goX, Spawn3.transform.position, Quaternion.identity) as GameObject;
NetworkServer.Spawn (go1);
GameObject go2 = GameObject.Instantiate (goY, Spawn4.transform.position, Quaternion.identity) as GameObject;
NetworkServer.Spawn (go2);
GameObject go3 = GameObject.Instantiate (goZ, Spawn1.transform.position, Quaternion.identity) as GameObject;
NetworkServer.Spawn (go3);
}
}
答案 0 :(得分:0)
好吧,我又做了! ...我在对象的注册码中输入了一个拼写错误。我在代码中进行非玩家注册。