- Home /
Can't instantiate "scene objects" [Unity Mirror Multiplayer]
I am trying to instantiate an object that already exists in the scene, so that I can enlarge it and "zoom" in on it, but when I play the game and hover over an object, instead of showing the zoomed card, this error shows up:
"Card1(Clone)(Clone) has already spawned. Don't call Instantiate for NetworkIdentities that were in the scene since the beginning (aka scene objects). Otherwise the client won't know which object to use for a SpawnSceneObject message."
NOTE: I am following a tutorial for a 2D Unity Card game with mirror (2019.2.15f1), and I am using a different version of Unity (2020.1.0f1).
First, I am instantiating objects into my game with this script, which never throws any errors.
[Command]
public void CmdDealCards()
{
for (int i = 0; i < 4; i++)
{
GameObject card = Instantiate(playerDeck[Random.Range(0, playerDeck.Count)], new Vector2(0, 0), Quaternion.identity);
NetworkServer.Spawn(card, connectionToClient);
RpcShowCard(card, "Dealt");
}
}
The problem comes when I try to instantiate these objects again later, here:
public void OnHoverEnter()
{
zoomCard = Instantiate(gameObject, new Vector2(Input.mousePosition.x, 540), Quaternion.identity);
zoomCard.transform.SetParent(Canvas.transform, true);
zoomCard.layer = LayerMask.NameToLayer("Zoom");
RectTransform rect = zoomCard.GetComponent<RectTransform>();
rect.sizeDelta = new Vector2(240, 354);
}
Your answer
Follow this Question
Related Questions
Is there any way to send gameobjects over the network? (Mirror) 1 Answer
My variables arent updating accordingly after I instantiated them 1 Answer
How do I select a prefab that was just instantiated from an editor window? 1 Answer
How to get position of instantiated object before it is destroyed 2 Answers