Search Unity

Creating Card/Deck Prefabs

Discussion in 'Getting Started' started by joostvanpoppel, Jun 7, 2018.

  1. joostvanpoppel

    joostvanpoppel

    Joined:
    Nov 24, 2017
    Posts:
    42
    Hi,

    I’m quite new to Unity and want to create a simple 2d card game with a normal deck of cards (2-3-4-5-6-7-8-10-J-Q-K-A and Clubs, Spades, Hearts, Diamonds). Therefore I want to create a GameObject Deck that does different operations on the set of cards like Shuffling, Dealing, Etc.

    My first goals are the Card / Deck prefabs. I’m going to work on Shuffling/dealing/etc later on.

    I’m wondering about several things;
    - Would you create a prefab with a face/back? Or would you just exchange a back with a face as soon as the game requires?
    - How would you create a Card-prefab? A prefab with which you can choose different values/suits from? Or a set of 52 prefabs/cards with each a different value/suits
    - How would you create/add the cards to the Deck? I have seen some solutions with lists/arrays/combined lists+arrays.

    Some things may not be very clear, so ask if needed,

    Thanks in advance,
    Joost
     
  2. verybinary

    verybinary

    Joined:
    Sep 23, 2015
    Posts:
    373
    I would...
    create a deck prefab just for interaction(solid cube, not split into 52 pieces)
    create a card prefab with the back, and a blank front. unsure on 52 textures for cards, or 4 textures for suits and 13 textures for interation

    the shuffling dealing etc would just be for show, and rely on rng for random cards
    draw a card == create card prefab, get rng from pool, update pool, process the card drawn
     
    Tset_Tsyung likes this.