0
votes

I am testing Unet and are now running into problem when spawning on the remote client. All works on the Server/Client side.

I have three non-player objects: "Orange", Apple" and "Banana" that i spawn. As i am testing i use very basic code to do this. However, when spawning, only two object spawns and the third get the following error:

Failed to spawn server object, assetId=3bd88da3adcb74d04addd82122b34fee netId=6 UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()

I have been trying to find a solution but this is the only message i get. I use the following spawn code:

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);


}
}
1
I suspect it has something to do with the prefab. Is the "Banana" prefab exactly the same structure as "Apple"?andeart
Are the Apple, Orange, and Banana registered in the NetworkManager inspector?user3071284

1 Answers

0
votes

Well, I did it again! ...i had a typo in the registration code for the object. I do the non-player registration in code.