- Home /
Need help with C# scripting matching cards
I have an array of cards to be dealt. My trouble is that each card has 2 versions (not just front and back but Front A and Front B) and I need to randomly select the cards to be dealt but then make sure both versions of the card are included. (I can use random.range to deal them. I just haven't been able to figure out how to get both versions included.)
Also, I am (obviously) a beginner so speak slowly please.
Answer by logicandchaos · Jun 29, 2020 at 05:39 PM
I would make the card object have 2 versions and then have the version selected randomly when shuffled, maybe use scriptable objects for all the card data that changes, then you can have 2 references set up: CardData version1; CardData version2;
then a variable to determine which version CardData selectedVersion;
then when shuffle for each card you would have to randomly pick a one, like do something like: int version=Random(1,2); if(version==1) selectedVersion=version1; if(version==2) selectedVersion=version2;
There are a lot of ways you could set it up, you could even use a list of CardData objects so that each card could have a different amount of versions, or to expand it.. etc.. This is mostly pseudo code.
Your answer
![](https://koobas.hobune.stream/wayback/20220613002052im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How do I move/copy functions from one script to another while playing? 1 Answer
Why my variable istn't always used? 2 Answers
touch movement script 0 Answers