Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Allign problem

Discussion in 'Scripting' started by Ceciaman, Aug 17, 2013.

  1. Ceciaman

    Ceciaman

    Joined:
    Jul 30, 2013
    Posts:
    52
    Hi,
    i've a sequence of cards.
    the card is a prefab with 2 plane Front/Back.
    This is a loop code for clone prefab.

    carteP1 = cp1.Split(","[0]);
    ss_cg1=carteP1.Length-1;
    distanza=0.0f-(((carteP1.Length/2)*0.08f)+0.15f);
    altezza=2.4f;
    profondita=-2.2f;

    for(int sss=0;sss<carteP1.Length-1;sss++){

    if(int.Parse(carteP1[sss])<=53){
    retro=54;
    }else{
    retro=55;
    }

    if(int.Parse(carteP1[sss])>53){
    dorso=int.Parse(carteP1[sss])-53;
    }else{
    dorso=int.Parse(carteP1[sss]);
    }


    profondita=profondita-0.0008f;
    distanza=distanza+0.08f;
    cardPrefab = (GameObject)Instantiate(Resources.Load("Carta"),new Vector3(distanza,altezza,profondita), transform.rotation);
    cardPrefab.transform.Rotate(-90,0,0);
    Transform[] cardPrefabint = cardPrefab.GetComponentsInChildren<Transform>();
    foreach(Transform cPint in cardPrefabint) {
    if(cPint.tag=="Retro") {
    cPint.renderer.material.mainTexture= Resources.Load(retro+"") as Texture;

    }

    if(cPint.tag=="Fronte") {
    cPint.renderer.material.mainTexture= Resources.Load(dorso+"") as Texture;

    }
    }
    }

    why i see the prefab card in front of main camera always over the others?
    $cards.jpg
     
    Last edited: Aug 17, 2013
  2. Kray-C

    Kray-C

    Joined:
    Apr 8, 2013
    Posts:
    152
    Basically because of its distance to the camera.
    But I think that is not the thing you really wanna know.
    You should clarify you question. What is your goal/problem?
     
  3. Ceciaman

    Ceciaman

    Joined:
    Jul 30, 2013
    Posts:
    52
    I've a sequence of cards:

    1 card pos(x,y,z);
    2 card pos(x+0,008f,y,z-0,0008f);
    3 card pos(x+0,016f,y,z-0,0018f);
    and so on......

    if i move main camera the cards change position (es. on picture);

    How can solve it?
     
  4. Ceciaman

    Ceciaman

    Joined:
    Jul 30, 2013
    Posts:
    52
    Ok, i've solve it
    there was a problem of overlapping.
    To fix it

    camera.transparencySortMode = TransparencySortMode.Orthographic;