I am not sure if I completely understand the problem, but in my game (XenoFeud, coming soon ) I am using the inventory system to check if, in your case, a card is still available.
Actually I got inspired to use this system also from a post from ddabrahim in 2016.
I will just quote his post here:
Just would like to add, you can also use the new inventory extension.
At the beginning just add 52 items to an inventory with the name 1,2,3,4โฆ52. Each item would represent a card in the deck and you can even call the inventory as"deck"
After, when you are about to take a card from the deck, just create a random number and check if the item with tha number as name is available in the โdeckโ or not.
If it available, create a card with tha animation displayed and remove item from the โdeckโ.
In case it is not available then generate a new random number until find one that is available using the while loop.
Each player could have it own inventory and just move the items/cards between the inventories by simply remove/add items and check which item/card is present in which inventory.
Also, from experience, instead of creating and deleting card objects, it easier to make a card game if objects are permanently present in the scene to display cards but displaying an empty animation or hidden when donโt needed and it become visible and display an animation only when needed. Basically think of it as empty slots waiting for information to display a card.
2 Likes