Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

201
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!