Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

1.1K
Visualizações
Can't instantiate "scene object" [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);
}
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I know this is a really late answer, but I came across it while running into the same issue, and maybe in the future, someone will do the same as me, so:

What you've done is attached the wrong prefab to your CardZoom script in the Inspector. Image of Inspector with Zoom Card attached

What I did, and presumably you also, was to attach Card1 here, which is where it was failing to duplicate the NetworkIdentity

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda