- Home /
The object Player(Clone) must be a prefab in the project view.
Okay, so I'm really not sure exactly what I'm doing wrong here. I'll be providing images and code
Alright, so now that that's out of the way, here's the error code:
he object Player(Clone) must be a prefab in the project view.
UnityEngine.Network:Instantiate(Object, Vector3, Quaternion, Int32)
GameServer:JoinGame(Boolean, NetworkPlayer) (at Assets/_Scripts/Networking/RPC/GameServer.cs:67)
UnityEngine.NetworkView:RPC(String, RPCMode, Object[])
This error reflects the following line of code:
PlayerObject = (GameObject)Network.Instantiate (PlayerObject, new Vector3 (55f, 1.1f, 40f), new Quaternion (0f, 0f, 0f, 0f), FFA);
Which sets the PlayerObject to None (Game Object)
What's even more confusing is that the Player prefab is actually instantiated inside of the game, but I can't reference from it using GetComponent, because the PlayerObject is set to null.
Answer by mediumal · Oct 18, 2014 at 10:41 PM
It sounds like it succeeded the first time. PlayerObject was initially the prefab ('Player'), and then you set it to the instance of the prefab ('Player(Clone)'). Instances of prefabs are given the name '(Clone)' by default, although you can override this.
Then that line was called again. This time PlayerObject is the clone instead of the prefab, hence the error.
What you should do is use a different variable name for the instances than the prefab to keep them separate:
PlayerObjectInstance = (GameObject)Network.Instantiate (PlayerObjectPrefab, new Vector3 (55f, 1.1f, 40f), new Quaternion (0f, 0f, 0f, 0f), FFA);
Your answer
Follow this Question
Related Questions
Spawning a prefab at another object's location 3 Answers
Issue Instantiating prefab in C# 0 Answers
How do I make a clone of a prefab appear on the correct layer? [5.2.2f1] 1 Answer
Prefabs instantiated from an array are keeping their public int value 1 Answer
How to break a prefab connection via c# 0 Answers