Instantiate on SpawnSpot don't work

I’m trying to get my cards to stack up in one spot, I can’t seem to get them to all line up on top of the spawn spot.

public RectTransform deckSpawn;
  
for (int i = 0; i < shuffled_deck.Count; i++)
            {
               
                GameObject playableDeck = (GameObject)Instantiate(shuffled_deck[i]);
                playableDeck.transform.SetParent(deckSpawn.transform);

            }

you are just setting the transform parent, you aren’t setting their position

try something like this

GameObject playableDeck = (GameObject)Instantiate(shuffled_deck[i]);
playableDeck.transform.SetParent(deckSpawn.transform);
playableDeck.transform.localPosition = new Vector3 (0f, card thickness, 0f);

I tried that it didn’t work, unity doesn’t recognize ‘card thickness’ haha… thats the first thing i tried before just without card and put 0f instead, didn’t work still :frowning:

card thickness should be replaced by the thickness of your cards eg 0.1f

So I messed about a little and done this…

 public RectTransform prefabdeck;
    public GameObject spawnSpot;
    public Transform c;
  
    // Update is called once per frame
    public void OnClicked () {
        Transform deck = Instantiate(prefabdeck[i], spawnSpot.transform.position, Quaternion.identity) as Transform;
        deck.transform.SetParent(c, true); // -- C is Canvas which the card becomes child of

Is they a way I can get it so i can spawn each card .1 above each other as they spawn in the same spot now :slight_smile: