- Home /
"GameObject Player is a prefab, it can't be spawned. This will cause errors in builds."
I have a LobbyNetworkManager and a player prefab that I have dropped in the, well, "Game Player Prefab" field. Now the following error occurs: "GameObject Player is a prefab, it can't be spawned. This will cause errors in builds." - and indeed, the player crashes upon game start while in build.
What is the correct way to spawn a game player using LobbyNetworkManager, if not with a prefab? I am using Unity 5.6.0b6.
Yes, NetworkIdentity is attached (set to Local Authority) and Inspector allows dropping the prefab in.
Answer by Heremeus · May 25, 2017 at 02:53 PM
Removing the Network Identity (and all components depending on it) and adding it again fixed the issue for me. I have a prefab that is instantiated in OnServerStart and spawned with NetworkServer.Spawn afterwards that was resulting in the error somehow.
Answer by tomfurrier · Apr 14, 2017 at 03:30 PM
It's intentional based on this post, and you have to instantiate the prefab first, then spawn the instantiated gameobject.
$$anonymous$$y issue was, I managed to break the prefab somehow maybe either readding the NetworkIdentity or changing it from a 2D to 3D rigidbody. Removing all the components left a couple of blocks remaining in the prefab. I then diffed that with the original object and removed the extra bits and it started working again. I'm guessing when Chikari's changed the serialization method the broken bits were lost in the conversion.
Thank you for your link. In the link, pappaxray2 gave a solution. You can change the gameobject's sceneid to zero(debug mod) then apply to prefab. The problem will be fixed. It caused apply prefab but there was some data in the scene file.
Answer by zeetu · Jul 03, 2017 at 04:08 PM
I was able to fix this error on 5.6.0f3 by resetting the NetworkIdenity Component (no need to remove and re-add it.
Answer by pappaxray2 · Apr 01, 2017 at 06:57 AM
There seems to be code to check for prefabs new in 5.6 which throws an error when a prefab is detected in NetworkServer.Spawn . Not sure why it is?
Answer by mrbenn · Sep 01, 2017 at 10:27 AM
I found another solution to this avoiding the need to remove the NetworkIdentity component:
Select the prefab
Change the Inspector to Debug mode
Locate the NetworkIdentity component
Expand "Scene Id" and change "Value" to 0
I guess this does a similar thing to resetting it
Your answer
Follow this Question
Related Questions
Player Prefab on Lobby Managers? 5 Answers
What can prevent a prefab network instantiation? 0 Answers
How to fix OnObjSpawn netId: 1 has invalid asset Id when using Lobby example in existing project 0 Answers
MLAPI error with two instances of networked object 0 Answers
Check if a player has Network View 0 Answers