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

202
Visualizações
Sprites with different z values not rendering in correct order

Starting off with some 2D in Unity. I am running 2019.4.12f1. I am following the "Let's Make Solitaire in Unity" by Megalomobile. I am dealing out the cards with the code:

IEnumerator SolitairDeal()
    {
        for (var i = 0; i < 7; i++)
        {
            var yoff = 0.0f;
            var zoff = 0.03f;
            foreach (var c in bottoms[i])
            {
                yield return new WaitForSeconds(0.1f);
                GameObject newCard = Instantiate(cardPrefab, new Vector3(bottomPos[i].transform.position.x, bottomPos[i].transform.position.y - yoff, bottomPos[i].transform.position.z - zoff), Quaternion.identity, bottomPos[i].transform);
                newCard.name = c;
                newCard.GetComponent<Selectable>().faceUp = c == bottoms[i][bottoms[i].Count - 1];

                yoff += 0.3f;
                zoff += 0.03f;
            }
        }
    }

When it renders in game mode I get this: enter image description here

If I switch to Scene mode to inspect the z values, they are correct and everything is properly rendered:enter image description here

I can increase the zoff value but as I do so, I am getting a good deal of parallax which I do not want. I have looked for creating a camera that eliminated parallax, but could not find one. I thought of using tags but managing that would get cumbersome depending on how many cards are in each stack.

Thank you in advance for any help.

EDIT: Thanks to the reference from @derHugo below I have found the fix. First, I changed the camera to Orthographic. Second I also had to change the camera's depth. Apparently if the depth is negative, it is still Perspective.

over 4 years ago · Santiago Trujillo
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